Skip to content

Commit ed144a5

Browse files
committed
Assert initscr() returns the screen's own window, drop the NEWS entry
The test now checks the identity the review asked for. The NEWS entry goes away because set_term(), newterm() and this code path are all new in 3.16 and unreleased, so no user could observe the crash.
1 parent 0cebe76 commit ed144a5

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

Lib/test/test_curses.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,16 +3073,18 @@ def test_new_prescr(self):
30733073
gc_collect()
30743074

30753075
def test_initscr_after_newterm_keeps_screen_alive(self):
3076-
# initscr() called while a newterm() screen is current returns a window
3077-
# for that screen, and the window must keep the screen alive. It used
3078-
# to be created without a screen, and using the window after the
3079-
# screen was collected read freed memory.
3076+
# initscr() called while a newterm() screen is current returns that
3077+
# screen's own standard window, so the window keeps the screen alive.
3078+
# It used to be a second wrapper created without a screen: using it
3079+
# after the screen was collected read freed memory, and both wrappers
3080+
# could delwin() the same window.
30803081
s1 = self.make_pty()
30813082
s2 = self.make_pty()
30823083
screen1 = curses.newterm('xterm', s1, s1)
30833084
screen2 = curses.newterm('xterm', s2, s2)
30843085
curses.set_term(screen1)
30853086
win = curses.initscr()
3087+
self.assertIs(win, screen1.stdscr)
30863088
curses.set_term(screen2)
30873089
del screen1
30883090
gc_collect()

Misc/NEWS.d/next/Library/2026-07-26-21-11-58.gh-issue-154751.q-YeEM.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)