New GitHub issue #119138 from cmang:<br>

<hr>

<pre>
# Bug report

### Bug description:

When using ncurses extended color pairs, introduced in Python 3.10 in issue #81163, the color pairs past 256 don't appear to be working correctly. Instead, when accessed, pairs 256+ repeat the behavior of pairs 0-255 instead of the colors set by curses.init_pair().

In my use case, curses.has_extended_color_support() == True and curses.COLORS == 256.

I can use curses.init_pair() to initialize color pairs past 255, and it lets me set them without any error. But when I go to display the colors, color pair 256 displays the same as color pair 0, 257 displays the same as 1, and so on.

I have made a small test program here to reproduce the issue by initializing, displaying, and letting you scroll through the extended color pairs: https://gist.github.com/cmang/7d366f677cd067c00e58a9d9c97141c5

The test program initializes 256 * 256 (65536) color pairs, using every FG and BG combination for FG and BG colors 0-255. It then lets you use the left/right arrow keys to scroll through the pairs. It requires an xterm-256color capable terminal. 

In the following screenshot, which shows each color pair number in its given color, you can see that the pairs repeat. The expected behavior is that pairs 256-512 should have a different background color set, as should the next 256 pairs.

<img width="715" alt="Screenshot 2024-05-18 at 4 18 41 AM" src="https://github.com/python/cpython/assets/261501/e7c8fd87-e885-4884-aa86-4bab50ac04a3">

@hpjansson @webs


### CPython versions tested on:

3.10, 3.11

### Operating systems tested on:

Linux, macOS
</pre>

<hr>

<a href="https://github.com/python/cpython/issues/119138">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>