You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gh-155976: Update update_lines_cols() in Modules/_cursesmodule.c to refresh COLORS and COLOR_PAIRS on module dictionaries when switching terminal screens via set_term() if start_color() is active. Also add unit test in Lib/test/test_curses.py.
This does not fix the issue: after set_term(), LINES and COLS are still those of the other screen; only COLORS and COLOR_PAIRS are now correct. The ncurses set_term() updates the latter two globals, but not LINES and COLS, which are set only when a screen is created, so they have to be taken from the current stdscr.
The test passes without the change in Modules/_cursesmodule.c: both screens have the same default size, and the COLORS checks compare two equally stale values. Use screens of different sizes and compare with screen.stdscr.getmaxyx() and the known number of colors.
This fixes it now: LINES, COLS, COLORS and COLOR_PAIRS follow the current screen after every set_term(), also for a screen with soft labels, and the test fails without the change in Modules/_cursesmodule.c.
Remaining:
set_term() is new in 3.16, so no NEWS entry is needed; please remove the file.
There is trailing whitespace on the two blank lines in the with block; the pre-commit check fails on it.
Move from test.support import os_helper to the imports at the top of the file.
newterm('xterm-256color', ...) should skip the test if the terminfo entry does not exist, as TermAttrsTests does.
The hasattr(curses, 'start_color') checks are not needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gh-155976: Update update_lines_cols() in Modules/_cursesmodule.c to refresh COLORS and COLOR_PAIRS on module dictionaries when switching terminal screens via set_term() if start_color() is active. Also add unit test in Lib/test/test_curses.py.