Skip to content

Commit ab2d481

Browse files
authored
bpo-43231: Fix test.test_curses.TestCurses.test_init_pair when running under -R (GH-24539)
1 parent a2f0654 commit ab2d481

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/test/test_curses.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,13 @@ def get_pair_limit(self):
926926
if (not curses.has_extended_color_support()
927927
or (6, 1) <= curses.ncurses_version < (6, 2)):
928928
pair_limit = min(pair_limit, SHORT_MAX)
929+
# If use_default_colors() is called, the upper limit of the extended
930+
# range may be restricted, so we need to check if the limit is still
931+
# correct
932+
try:
933+
curses.init_pair(pair_limit, 0, 0)
934+
except ValueError:
935+
pair_limit = curses.COLOR_PAIRS
929936
return pair_limit
930937

931938
@requires_colors

0 commit comments

Comments
 (0)