Skip to content

Commit 157e388

Browse files
gh-157546: Add missing docstrings in curses
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 df02e26 commit 157e388

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
@@ -5534,7 +5534,14 @@ static PyMethodDef PyCursesScreen_methods[] = {
55345534
{NULL, NULL} /* sentinel */
55355535
};
55365536

5537+
PyDoc_STRVAR(PyCursesScreen_Type_doc,
5538+
"A curses screen.\n"
5539+
"\n"
5540+
"Screen objects are returned by newterm() and new_prescr(), and represent\n"
5541+
"a terminal together with its standard window, stdscr.");
5542+
55375543
static PyType_Slot PyCursesScreen_Type_slots[] = {
5544+
{Py_tp_doc, (void *)PyCursesScreen_Type_doc},
55385545
{Py_tp_methods, PyCursesScreen_methods},
55395546
{Py_tp_getset, PyCursesScreen_getsets},
55405547
{Py_tp_dealloc, PyCursesScreen_dealloc},
@@ -6929,12 +6936,12 @@ _curses.initscr
69296936
69306937
Initialize the library.
69316938
6932-
Return a WindowObject which represents the whole screen.
6939+
Return a window object which represents the whole screen.
69336940
[clinic start generated code]*/
69346941

69356942
static PyObject *
69366943
_curses_initscr_impl(PyObject *module)
6937-
/*[clinic end generated code: output=619fb68443810b7b input=514f4bce1821f6b5]*/
6944+
/*[clinic end generated code: output=619fb68443810b7b input=e2bf3a061b7d948a]*/
69386945
{
69396946
WINDOW *win;
69406947

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)