]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43231: Fix test.test_curses.TestCurses.test_init_pair when running under -R ...
authorPablo Galindo <Pablogsal@gmail.com>
Mon, 15 Feb 2021 21:35:48 +0000 (21:35 +0000)
committerGitHub <noreply@github.com>
Mon, 15 Feb 2021 21:35:48 +0000 (22:35 +0100)
Lib/test/test_curses.py

index a9f7001d39f08d8428c5251f139f22d16b9afa92..f6bd27d02e43158d16355fae621795d340c74553 100644 (file)
@@ -926,6 +926,13 @@ class TestCurses(unittest.TestCase):
             if (not curses.has_extended_color_support()
                     or (6, 1) <= curses.ncurses_version < (6, 2)):
                 pair_limit = min(pair_limit, SHORT_MAX)
+            # If use_default_colors() is called, the upper limit of the extended
+            # range may be restricted, so we need to check if the limit is still
+            # correct
+            try:
+                curses.init_pair(pair_limit, 0, 0)
+            except ValueError:
+                pair_limit = curses.COLOR_PAIRS
         return pair_limit
 
     @requires_colors