Skip to content

Commit 2c20427

Browse files
committed
gh-155258: Make the curses.complexstr signature introspectable
1 parent e12ee02 commit 2c20427

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

Lib/test/test_curses.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,10 @@ def test_complexstr(self):
696696
lambda: curses.complexstr([cc('A')], attr=B))
697697
self.assertRaises(TypeError,
698698
lambda: curses.complexstr(['A'], pair=0))
699+
# The signature is introspectable: attr and pair have a default that
700+
# can be rendered.
701+
self.assertEqual(str(inspect.signature(curses.complexstr)),
702+
'(cells, /, attr=None, pair=None)')
699703

700704
def test_in_wchstr(self):
701705
# in_wchstr() returns a complexstr -- the styled-cell counterpart of

Modules/_cursesmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,9 +1412,9 @@ _curses.complexstr.__new__ as complexstr_new
14121412
cells: object
14131413
An iterable of cells, each a complexchar or a str.
14141414
/
1415-
attr: object = NULL
1415+
attr: object(c_default="NULL") = None
14161416
Attributes applied to every cell (only with a string).
1417-
pair: object = NULL
1417+
pair: object(c_default="NULL") = None
14181418
Color pair applied to every cell (only with a string).
14191419
14201420
An immutable string of styled wide-character cells.
@@ -1431,7 +1431,7 @@ rendition, and attr and pair must be omitted.
14311431
static PyObject *
14321432
complexstr_new_impl(PyTypeObject *type, PyObject *cells, PyObject *attr,
14331433
PyObject *pair)
1434-
/*[clinic end generated code: output=ef8a53143d35a32a input=9b75aee973cc6565]*/
1434+
/*[clinic end generated code: output=ef8a53143d35a32a input=f152717ac17b5b88]*/
14351435
{
14361436
cursesmodule_state *state = get_cursesmodule_state_by_cls(type);
14371437
/* A string is split into cells (grouping combining characters), not

Modules/clinic/_cursesmodule.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)