Skip to content

Commit b1e2766

Browse files
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.
1 parent b426caa commit b1e2766

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

Lib/curses/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
from _curses import *
14+
import _curses
1415
import os as _os
1516
import sys as _sys
1617

@@ -33,6 +34,7 @@ def initscr():
3334
if key.startswith(('ACS_', 'WACS_')) or key in ('LINES', 'COLS'):
3435
setattr(curses, key, value)
3536
return stdscr
37+
initscr.__doc__ = _curses.initscr.__doc__
3638

3739
# newterm() is wrapped for the same reason as initscr(): the ACS_* and WACS_*
3840
# constants and LINES/COLS only become available once a terminal is
@@ -50,6 +52,7 @@ def newterm(type=None, fd=None, infd=None, /):
5052
if key.startswith(('ACS_', 'WACS_')) or key in ('LINES', 'COLS'):
5153
setattr(curses, key, value)
5254
return screen
55+
newterm.__doc__ = _curses.newterm.__doc__
5356

5457
# This is a similar wrapper for start_color(), which adds the COLORS and
5558
# COLOR_PAIRS variables which are only available after start_color() is
@@ -60,6 +63,7 @@ def start_color():
6063
_curses.start_color()
6164
curses.COLORS = _curses.COLORS
6265
curses.COLOR_PAIRS = _curses.COLOR_PAIRS
66+
start_color.__doc__ = _curses.start_color.__doc__
6367

6468
# Import Python has_key() implementation if _curses doesn't contain has_key()
6569

Modules/_cursesmodule.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,7 +5536,14 @@ static PyMethodDef PyCursesScreen_methods[] = {
55365536
{NULL, NULL} /* sentinel */
55375537
};
55385538

5539+
PyDoc_STRVAR(PyCursesScreen_Type_doc,
5540+
"A curses screen.\n"
5541+
"\n"
5542+
"Screen objects are returned by newterm() and new_prescr(), and represent\n"
5543+
"a terminal together with its standard window, stdscr.");
5544+
55395545
static PyType_Slot PyCursesScreen_Type_slots[] = {
5546+
{Py_tp_doc, (void *)PyCursesScreen_Type_doc},
55405547
{Py_tp_methods, PyCursesScreen_methods},
55415548
{Py_tp_getset, PyCursesScreen_getsets},
55425549
{Py_tp_dealloc, PyCursesScreen_dealloc},
@@ -6931,12 +6938,12 @@ _curses.initscr
69316938
69326939
Initialize the library.
69336940
6934-
Return a WindowObject which represents the whole screen.
6941+
Return a window object which represents the whole screen.
69356942
[clinic start generated code]*/
69366943

69376944
static PyObject *
69386945
_curses_initscr_impl(PyObject *module)
6939-
/*[clinic end generated code: output=619fb68443810b7b input=514f4bce1821f6b5]*/
6946+
/*[clinic end generated code: output=619fb68443810b7b input=e2bf3a061b7d948a]*/
69406947
{
69416948
WINDOW *win;
69426949

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)