Skip to content

gh-156951: Do not truncate the color pair in curses.slk_color() - #156952

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
fedonman:fix-curses-slk-color-pair-width
Sep 7, 2026
Merged

gh-156951: Do not truncate the color pair in curses.slk_color()#156952
serhiy-storchaka merged 1 commit into
python:mainfrom
fedonman:fix-curses-slk-color-pair-width

Conversation

@fedonman

@fedonman fedonman commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

slk_color() cast its color pair to a short, so pairs of 32768 and above were rejected and a pair whose low 16 bits named a valid pair was silently applied in its place. It now calls extended_slk_color() under the module's existing _NCURSES_EXTENDED_COLOR_FUNCS guard, as slk_attr_set() and window.color_set() already do.

No Misc/NEWS.d entry: slk_color() is versionadded:: next and has not been in a release.

slk_color() cast its color pair to a short before calling ncurses, while
the pair converter accepts pairs up to INT_MAX on a build with extended
color support.  Pairs of 32768 and above were rejected although the rest
of the module accepts them, and a pair whose low 16 bits named a valid
pair was silently applied in place of the one that was asked for.

Call extended_slk_color() under the module's existing
_NCURSES_EXTENDED_COLOR_FUNCS guard, as slk_attr_set() and
window.color_set() already do, and keep the legacy call for builds
without it.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@serhiy-storchaka
serhiy-storchaka merged commit dcc4e52 into python:main Sep 7, 2026
100 of 102 checks passed
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Sep 12, 2026
…pythonGH-156952)

slk_color() cast its color pair to a short, so pairs of 32768 and above
were rejected or silently applied as a different pair.  Use
extended_slk_color() when it is available, like slk_attr_set() does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants