You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
curses: remove ncurses assumptions from the module and its tests #154934
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.
Activity
gh-154934: Remove ncurses assumptions from curses and its tests (GH-1…
pythongh-154934: Remove ncurses assumptions from curses and its tests (…