gh-157170: Restore use_env() after test_use_prescr_screen in test_curses - #157171
Conversation
…st_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.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Good catch, and thank you for the trace.
Please drop the NEWS entry. This is a fix to unreleased test. It does not need a NEWS entry.
Please simplify the comment, it is too verbose. One addition line would be enough.
|
Thank you. Both done in a779f46:
The diff is two added lines. Re-ran I have made the requested changes; please review again |
|
Thanks for making the requested changes! : please review the changes made to this pull request. |
|
test_use_prescr_screenturnsuse_envoff to show that anew_prescr()screen can be used to affect state beforeinitscr(), and never turns it back on.curses.use_env()calls ncurses'use_env(), which sets the process-wide default (_nc_prescreen.use_env) that every later screen copies, not a property of the screen that is current at the time. With it off, ncurses sizes a screen from the terminfolines/colscapabilities alone, and thelinuxentry used by the CI runners has none, so everynewterm()for the rest of the process returns NULL. That is the 138 errorstest_cursesreports in the parallel phase of every Ubuntu CI run (all 31 Ubuntu job runs in the last 8 successful runs on main); the sequential rerun passes only because it re-runs the failed tests by name and so never runsScreenTestsfirst. Details, including an ncurses trace of the failingnewterm(), are in the issue.This restores the setting with
addCleanup(). Verified on Ubuntu 25.10 with ncurses 6.5 (the newterm-basedsetUp()needs ncurses 6.5 or newer):TERM=linux ./python -m test test_curses -u curses: 138 errors before, passes after (three consecutive runs).TERM=linux ./python -m test --fast-ci test_curses: no rerun needed after.TERM=xtermstill passes.On macOS the
ScreenTestsare skipped (ncurses 6.0), which is why this was invisible on developer machines.