https://github.com/python/cpython/commit/b1e2766ad6d9dfcb35bc37917484354f8cff9ea6
commit: b1e2766ad6d9dfcb35bc37917484354f8cff9ea6
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-09-21T14:49:28+03:00
summary:
gh-157546: Add missing docstrings in curses (GH-157547)
The Python wrappers initscr(), newterm() and start_color() now use the
docstrings of the wrapped C functions, and the screen type has a
docstring.
files:
M Lib/curses/__init__.py
M Modules/_cursesmodule.c
M Modules/clinic/_cursesmodule.c.h
diff --git a/Lib/curses/__init__.py b/Lib/curses/__init__.py
index 1e372ecdc831396..bdc342ed1c25ef6 100644
--- a/Lib/curses/__init__.py
+++ b/Lib/curses/__init__.py
@@ -11,6 +11,7 @@
"""
from _curses import *
+import _curses
import os as _os
import sys as _sys
@@ -33,6 +34,7 @@ def initscr():
if key.startswith(('ACS_', 'WACS_')) or key in ('LINES', 'COLS'):
setattr(curses, key, value)
return stdscr
+initscr.__doc__ = _curses.initscr.__doc__
# newterm() is wrapped for the same reason as initscr(): the ACS_* and WACS_*
# constants and LINES/COLS only become available once a terminal is
@@ -50,6 +52,7 @@ def newterm(type=None, fd=None, infd=None, /):
if key.startswith(('ACS_', 'WACS_')) or key in ('LINES', 'COLS'):
setattr(curses, key, value)
return screen
+ newterm.__doc__ = _curses.newterm.__doc__
# This is a similar wrapper for start_color(), which adds the COLORS and
# COLOR_PAIRS variables which are only available after start_color() is
@@ -60,6 +63,7 @@ def start_color():
_curses.start_color()
curses.COLORS = _curses.COLORS
curses.COLOR_PAIRS = _curses.COLOR_PAIRS
+start_color.__doc__ = _curses.start_color.__doc__
# Import Python has_key() implementation if _curses doesn't contain has_key()
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index fd65cbb0bf67a81..401b777be23caa6 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -5536,7 +5536,14 @@ static PyMethodDef PyCursesScreen_methods[] = {
{NULL, NULL} /* sentinel */
};
+PyDoc_STRVAR(PyCursesScreen_Type_doc,
+"A curses screen.\n"
+"\n"
+"Screen objects are returned by newterm() and new_prescr(), and represent\n"
+"a terminal together with its standard window, stdscr.");
+
static PyType_Slot PyCursesScreen_Type_slots[] = {
+ {Py_tp_doc, (void *)PyCursesScreen_Type_doc},
{Py_tp_methods, PyCursesScreen_methods},
{Py_tp_getset, PyCursesScreen_getsets},
{Py_tp_dealloc, PyCursesScreen_dealloc},
@@ -6931,12 +6938,12 @@ _curses.initscr
Initialize the library.
-Return a WindowObject which represents the whole screen.
+Return a window object which represents the whole screen.
[clinic start generated code]*/
static PyObject *
_curses_initscr_impl(PyObject *module)
-/*[clinic end generated code: output=619fb68443810b7b input=514f4bce1821f6b5]*/
+/*[clinic end generated code: output=619fb68443810b7b input=e2bf3a061b7d948a]*/
{
WINDOW *win;
diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h
index 256d7ea9255948a..7b83727a20b68aa 100644
--- a/Modules/clinic/_cursesmodule.c.h
+++ b/Modules/clinic/_cursesmodule.c.h
@@ -4191,7 +4191,7 @@ PyDoc_STRVAR(_curses_initscr__doc__,
"\n"
"Initialize the library.\n"
"\n"
-"Return a WindowObject which represents the whole screen.");
+"Return a window object which represents the whole screen.");
#define _CURSES_INITSCR_METHODDEF \
{"initscr", (PyCFunction)_curses_initscr, METH_NOARGS,
_curses_initscr__doc__},
@@ -6749,4 +6749,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=bbaebaa6961d42d3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=cc7b5de1c82ae56b input=a9049054013a1b77]*/
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]