Skip to content

Commit c2ad600

Browse files
committed
gh-157170: Restore use_env() after test_use_prescr_screen in test_curses
curses.use_env() sets a process-wide ncurses default, not a property of the screen it is called on. test_use_prescr_screen turned it off and never turned it back on, so every newterm() in the rest of the process took the screen size from terminfo alone. For a terminfo entry with no size, such as "linux" on the CI runners, that makes newterm() return NULL: test_curses failed with 138 errors in the parallel phase of every Ubuntu CI run and only passed on the rerun, which skips ScreenTests.
1 parent 7a562c4 commit c2ad600

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/test/test_curses.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3459,6 +3459,10 @@ def test_use_prescr_screen(self):
34593459
with self.assertRaises(curses.error):
34603460
prescr.use(func)
34613461
# Affecting the state before initscr() is what such a screen is for.
3462+
# use_env() sets a process-wide default rather than a property of the
3463+
# screen it is called on, so restore it: with it off, newterm() has no
3464+
# size for a terminfo entry without one (such as "linux") and fails.
3465+
self.addCleanup(curses.use_env, True)
34623466
prescr.use(lambda scr: curses.use_env(False))
34633467
# The current screen is unchanged.
34643468
screen.stdscr.refresh()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix ``test_curses`` failing with 138 errors when ``TERM`` names a terminfo
2+
entry without a size, such as ``linux`` on the CI runners:
3+
``test_use_prescr_screen`` now restores :func:`curses.use_env`.

0 commit comments

Comments
 (0)