Skip to content

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

Open
fedonman wants to merge 1 commit into
python:mainfrom
fedonman:fix-curses-slk-color-pair-width
Open

gh-156951: Do not truncate the color pair in curses.slk_color()#156952
fedonman wants to merge 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.
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.

1 participant