Bug report
The curses module and its tests assume in several places that the library behind them is ncurses.
PyCurses_ConvertToChtype() and PyCurses_ConvertToCchar_t() parse the integer forms of addch() and friends through a signed long, and attr_converter() through an unsigned long. The width of a chtype is up to the library: with a 64-bit one, addch(ord('A') | curses.color_pair(589823)) fails with OverflowError. Parsing as unsigned long long fixes it and changes nothing for a narrower chtype.
test_curses decides what a cell can hold by probing for a function, and assumes throughout that the integer form of a character is its locale byte and that inch() returns that byte. Exposing whether the module was built for wide characters (_curses._wide_character_support) lets it ask directly.
Textbox._decode() masks an integer keystroke with A_CHARTEXT, which is the character field of a cell rather than a byte, and _printable_key() calls anything up to 0xff printable although key codes need not start above a byte.
None of this changes behaviour on ncurses, where chtype is 32 bits, A_CHARTEXT is 0xff and KEY_MIN is above a byte. It is the part of gh-85796 that is not specific to PDCurses.
Linked PRs
Bug report
The
cursesmodule and its tests assume in several places that the library behind them is ncurses.PyCurses_ConvertToChtype()andPyCurses_ConvertToCchar_t()parse the integer forms ofaddch()and friends through a signedlong, andattr_converter()through anunsigned long. The width of achtypeis up to the library: with a 64-bit one,addch(ord('A') | curses.color_pair(589823))fails withOverflowError. Parsing asunsigned long longfixes it and changes nothing for a narrowerchtype.test_cursesdecides what a cell can hold by probing for a function, and assumes throughout that the integer form of a character is its locale byte and thatinch()returns that byte. Exposing whether the module was built for wide characters (_curses._wide_character_support) lets it ask directly.Textbox._decode()masks an integer keystroke withA_CHARTEXT, which is the character field of a cell rather than a byte, and_printable_key()calls anything up to0xffprintable although key codes need not start above a byte.None of this changes behaviour on ncurses, where
chtypeis 32 bits,A_CHARTEXTis0xffandKEY_MINis above a byte. It is the part of gh-85796 that is not specific to PDCurses.Linked PRs