gh-154934: Remove ncurses assumptions from curses and its tests - #154940
Merged
serhiy-storchaka merged 1 commit intoJul 30, 2026
Conversation
Parse the integer forms of addch() and friends as unsigned long long: the width of a chtype is up to the library. Expose _curses._wide_character_support so that the tests can ask what a cell holds instead of probing for a function. Mask an integer keystroke in textpad as the byte it is, and keep the key codes out of the printable range.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The integer forms of
addch()and friends were parsed through a signedlong, attributes through anunsigned long, and theslk_attr*()functions took anintor along; they now useunsigned long longandattr_t, the width of achtypebeing up to the library. With a 64-bit one,addch(ord('A') | curses.color_pair(589823))no longer raisesOverflowError.test_cursesdecided whether cells hold wide characters by probing for a function;_curses._wide_character_supportreports what the module was built for. A_char_code()helper gives the integer a character is written as, replacing the same encode-and-check written out in six tests.Textbox._decode()masked an integer keystroke withA_CHARTEXT, which is a byte only where a cell holds one, and_printable_key()treated everything up to0xffas printable although key codes may start below that.Nothing changes on ncurses, where a
chtypeis 32 bits,A_CHARTEXTis0xffandKEY_MINis above a byte.test_cursespasses there inC.utf8,uk_UA.koi8uanden_US.iso885915, and against PDCursesMod in five configurations (wide and narrow, 32- and 64-bitchtype, forced UTF-8), of which the 64-bit ones exercise the widening.