From 2c204277c33a2069d54bdc99331d005f15acbe97 Mon Sep 17 00:00:00 2001 From: Vyron Vasileiadis Date: Thu, 6 Aug 2026 00:20:48 +0300 Subject: [PATCH] gh-155258: Make the curses.complexstr signature introspectable --- Lib/test/test_curses.py | 4 ++++ Modules/_cursesmodule.c | 6 +++--- Modules/clinic/_cursesmodule.c.h | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index f7584a39b182d99..6f53762b4c563bb 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -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 diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 07e924b0fc564bc..3e0b9588e2b8359 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -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 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. @@ -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 diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h index b4cb294e3bb61a5..b7b5f3a9f60a284 100644 --- a/Modules/clinic/_cursesmodule.c.h +++ b/Modules/clinic/_cursesmodule.c.h @@ -102,7 +102,7 @@ complexchar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } PyDoc_STRVAR(complexstr_new__doc__, -"complexstr(cells, /, attr=, pair=)\n" +"complexstr(cells, /, attr=None, pair=None)\n" "--\n" "\n" "An immutable string of styled wide-character cells.\n" @@ -6585,4 +6585,4 @@ _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored #ifndef _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF #define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF #endif /* !defined(_CURSES_ASSUME_DEFAULT_COLORS_METHODDEF) */ -/*[clinic end generated code: output=680f621e7c1f101b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f1b79ac96624e268 input=a9049054013a1b77]*/