Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ def test_complexstr(self):
lambda: curses.complexstr([cc('A')], attr=B))
self.assertRaises(TypeError,
lambda: curses.complexstr(['A'], pair=0))
# The signature is introspectable: attr and pair have a default that
# can be rendered.
self.assertEqual(str(inspect.signature(curses.complexstr)),
'(cells, /, attr=None, pair=None)')

def test_in_wchstr(self):
# in_wchstr() returns a complexstr -- the styled-cell counterpart of
Expand Down
6 changes: 3 additions & 3 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,9 +1412,9 @@ _curses.complexstr.__new__ as complexstr_new
cells: object
An iterable of cells, each a complexchar or a str.
/
attr: object = NULL
attr: object(c_default="NULL") = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_weakref.proxy uses the same declaration and folds the explicit value back — if (callback == Py_None) callback = NULL; in Objects/weakrefobject.c — so proxy(x, None) behaves like omitting it.

Here None counts as "given" rather than "omitted".

complexstr(["A"], attr=None)  TypeError: attr and pair can only be given with a string

So the signature would advertise a default that can't be passed. Should explicit None be treated as "not given" here?

Attributes applied to every cell (only with a string).
pair: object = NULL
pair: object(c_default="NULL") = None
Color pair applied to every cell (only with a string).

An immutable string of styled wide-character cells.
Expand All @@ -1431,7 +1431,7 @@ rendition, and attr and pair must be omitted.
static PyObject *
complexstr_new_impl(PyTypeObject *type, PyObject *cells, PyObject *attr,
PyObject *pair)
/*[clinic end generated code: output=ef8a53143d35a32a input=9b75aee973cc6565]*/
/*[clinic end generated code: output=ef8a53143d35a32a input=f152717ac17b5b88]*/
{
cursesmodule_state *state = get_cursesmodule_state_by_cls(type);
/* A string is split into cells (grouping combining characters), not
Expand Down
4 changes: 2 additions & 2 deletions Modules/clinic/_cursesmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading