Skip to content

Commit e471712

Browse files
gh-144067: Document terminal leak when initscr() follows setupterm() (GH-152624)
The curses library keeps a single current terminal: calling initscr() or newterm() after setupterm() abandons the terminal that setupterm() allocated without freeing it. This cannot be fixed safely in code (freeing the terminal would break the capsule API and pending terminfo queries), so document the behavior, with a cross-reference from initscr() and newterm(). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3428959 commit e471712

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Doc/library/curses.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Initialization and termination
7676
Initialize the library. Return a :ref:`window <curses-window-objects>` object
7777
which represents the whole screen.
7878

79+
See :func:`setupterm` for a caveat about calling it before this function.
80+
7981
.. note::
8082

8183
If there is an error opening the terminal, the underlying curses library may
@@ -106,6 +108,8 @@ Initialization and termination
106108
The new screen becomes the current one.
107109
Use :func:`set_term` to switch between screens.
108110

111+
See :func:`setupterm` for a caveat about calling it before this function.
112+
109113
.. versionadded:: next
110114

111115
.. function:: new_prescr()
@@ -959,6 +963,13 @@ Terminfo database
959963
terminfo database entry could not be read. If the terminal has already
960964
been initialized, this function has no effect.
961965

966+
.. note::
967+
968+
Calling :func:`initscr` or :func:`newterm` after :func:`setupterm`
969+
leaks the terminal that :func:`setupterm` allocated:
970+
the curses library keeps only a single current terminal
971+
and does not free the previously allocated one.
972+
962973
.. function:: tigetflag(capname)
963974

964975
Return the value of the Boolean capability corresponding to the terminfo

0 commit comments

Comments
 (0)