https://github.com/python/cpython/commit/22c797005d1eaa2b03bcd9d858c2525a1d1560c4
commit: 22c797005d1eaa2b03bcd9d858c2525a1d1560c4
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-07-23T15:37:43Z
summary:

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) <[email protected]>

files:
M Lib/test/test_curses.py

diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index 4ca5dd73f55afe..8aecb1e3a7a42d 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -1997,12 +1997,15 @@ def test_dynamic_color_pairs(self):
         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():

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to