From 54705a47ae98ccfa5b712e0cf549dae19704a466 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 2 Jul 2026 17:45:25 +0300 Subject: [PATCH] [3.15] gh-144067: Document terminal leak when initscr() follows setupterm() (GH-152624) curses.newterm() does not exist in 3.15, so the note mentions only initscr(). (cherry picked from commit e471712958515b65b737ac742b294acf7de9220c) Co-authored-by: Serhiy Storchaka Co-Authored-By: Claude Opus 4.8 --- Doc/library/curses.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst index 621e3d6ad2043a0..f2115a236f25832 100644 --- a/Doc/library/curses.rst +++ b/Doc/library/curses.rst @@ -324,6 +324,8 @@ The module :mod:`!curses` defines the following functions: Initialize the library. Return a :ref:`window ` object which represents the whole screen. + See :func:`setupterm` for a caveat about calling it before this function. + .. note:: If there is an error opening the terminal, the underlying curses library may @@ -593,6 +595,13 @@ The module :mod:`!curses` defines the following functions: terminfo database entry could not be read. If the terminal has already been initialized, this function has no effect. + .. note:: + + Calling :func:`initscr` after :func:`setupterm` + leaks the terminal that :func:`setupterm` allocated: + the curses library keeps only a single current terminal + and does not free the previously allocated one. + .. function:: start_color()