From: Serhiy Storchaka Date: Thu, 23 Jul 2026 15:37:43 +0000 (+0300) Subject: gh-154525: Skip ncurses find_pair()/alloc_pair() reuse checks before 6.3 (GH-154543) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22c797005d1eaa2b03bcd9d858c2525a1d1560c4;p=thirdparty%2FPython%2Fcpython.git gh-154525: Skip ncurses find_pair()/alloc_pair() reuse checks before 6.3 (GH-154543) find_pair() and reuse in alloc_pair() were fixed in ncurses 6.3 (patch 20200411). On earlier versions find_pair() returns -1 and alloc_pair() allocates a fresh pair instead of reusing an equal one, so test_dynamic_color_pairs failed on ncurses 6.1 and 6.2. Co-authored-by: Claude Opus 4.8 (1M context) --- diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index 4ca5dd73f55a..8aecb1e3a7a4 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -1997,12 +1997,15 @@ class TestCurses(unittest.TestCase): pair = curses.alloc_pair(fg, bg) self.assertGreater(pair, 0) self.assertEqual(curses.pair_content(pair), (fg, bg)) - # The same combination of colors reuses the same pair. - self.assertEqual(curses.alloc_pair(fg, bg), pair) - self.assertEqual(curses.find_pair(fg, bg), pair) - # Once freed, the pair is no longer found. - self.assertIsNone(curses.free_pair(pair)) - self.assertEqual(curses.find_pair(fg, bg), -1) + if getattr(curses, 'ncurses_version', (6, 3)) >= (6, 3): + # The same combination of colors reuses the same pair. + self.assertEqual(curses.alloc_pair(fg, bg), pair) + self.assertEqual(curses.find_pair(fg, bg), pair) + # Once freed, the pair is no longer found. + self.assertIsNone(curses.free_pair(pair)) + self.assertEqual(curses.find_pair(fg, bg), -1) + else: + self.assertIsNone(curses.free_pair(pair)) # Error paths. for color in self.bad_colors2():