Skip to content

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

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-144067-setupterm-leak-note
Jul 2, 2026
Merged

gh-144067: Document terminal leak when initscr() follows setupterm()#152624
serhiy-storchaka merged 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

@serhiy-storchaka serhiy-storchaka merged commit e471712 into python:main Jul 2, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jul 2, 2026
@serhiy-storchaka serhiy-storchaka deleted the gh-144067-setupterm-leak-note branch July 2, 2026 14:19
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 2, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e471712958515b65b737ac742b294acf7de9220c 3.15

@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

GH-152894 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 2, 2026
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2026
…term() (GH-152624) (GH-152894)

(cherry picked from commit e471712)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2026
…term() (GH-152624) (GH-152894) (GH-152898)

(cherry picked from commit e471712)
(cherry picked from commit 46b48ff)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2026
…term() (GH-152624) (GH-152894) (GH-152899)

(cherry picked from commit e471712)
(cherry picked from commit 46b48ff)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant