Skip to content

gh-144067: Document terminal leak when initscr() follows setupterm()#152624

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-144067-setupterm-leak-note
Open

gh-144067: Document terminal leak when initscr() follows setupterm()#152624
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-144067-setupterm-leak-note

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Document that calling :func:initscr or :func:newterm after :func:setupterm leaks the terminal that setupterm() allocated: the curses library keeps only a single current terminal and does not free the previous one.

This one-time libtinfo leak cannot be fixed safely in code -- freeing the terminal would break the capsule API and any pending terminfo queries (see the discussion on the issue) -- so the behavior is documented instead, with a cross-reference from :func:initscr and :func:newterm.

…erm()

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>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33361004 | 📁 Comparing a3b349f against main (089e6f6)

  🔍 Preview build  

1 file changed
± library/curses.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant