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.termattrs() returns a negative value on italic terminals #154874
curses.termattrs() returns a negative value on a terminal that advertises A_ITALIC (bit 31), so its result cannot be passed back to the attribute functions:
>>> curses.termattrs()
-2130771968
>>> curses.term_attrs() # the same bits, unsigned
2164195328
>>> curses.newwin(1, 1).attrset(curses.termattrs())
OverflowError: can't convert negative value to unsigned int
This is a regression in 3.15. Up to 3.14 the macro behind it returned PyLong_FromLong((long) X()), and on a 64-bit long the mask stayed positive. GH-134327 rewrote it to check for ERR through an int, which sign-extends:
intrtn=X();
if (rtn==ERR) { ... }
returnPyLong_FromLong(rtn);
ERR checking is right for baudrate(), the macro's only other user, but termattrs() returns a chtype mask, not a status. term_attrs(), slk_attr() and window.getattrs() all return theirs with PyLong_FromUnsignedLong.
Activity
gh-154874: Fix the sign of curses.termattrs() (GH-154875)
[3.15] pythongh-154874: Fix the sign of curses.termattrs() (pythonGH-…
pythongh-154874: Fix the sign of curses.termattrs() (pythonGH-154875)