Skip to content

Commit 22c7970

Browse files
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) <noreply@anthropic.com>
1 parent aad438b commit 22c7970

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

Lib/test/test_curses.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,12 +1997,15 @@ def test_dynamic_color_pairs(self):
19971997
pair = curses.alloc_pair(fg, bg)
19981998
self.assertGreater(pair, 0)
19991999
self.assertEqual(curses.pair_content(pair), (fg, bg))
2000-
# The same combination of colors reuses the same pair.
2001-
self.assertEqual(curses.alloc_pair(fg, bg), pair)
2002-
self.assertEqual(curses.find_pair(fg, bg), pair)
2003-
# Once freed, the pair is no longer found.
2004-
self.assertIsNone(curses.free_pair(pair))
2005-
self.assertEqual(curses.find_pair(fg, bg), -1)
2000+
if getattr(curses, 'ncurses_version', (6, 3)) >= (6, 3):
2001+
# The same combination of colors reuses the same pair.
2002+
self.assertEqual(curses.alloc_pair(fg, bg), pair)
2003+
self.assertEqual(curses.find_pair(fg, bg), pair)
2004+
# Once freed, the pair is no longer found.
2005+
self.assertIsNone(curses.free_pair(pair))
2006+
self.assertEqual(curses.find_pair(fg, bg), -1)
2007+
else:
2008+
self.assertIsNone(curses.free_pair(pair))
20062009

20072010
# Error paths.
20082011
for color in self.bad_colors2():

0 commit comments

Comments
 (0)