Commit da6982e
gh-154874: Fix curses.termattrs() returning a negative attribute mask
termattrs() returns a chtype mask, but GH-134327 routed it through the
NoArgReturnIntFunctionBody macro, which stores the result in an int to
compare it against ERR. On a terminal that advertises A_ITALIC, the
topmost bit of a 32-bit mask, that sign-extends and the mask comes back
negative, so it can no longer be passed to the attribute functions:
>>> curses.termattrs()
-2130771968
>>> curses.newwin(1, 1).attrset(curses.termattrs())
OverflowError: can't convert negative value to unsigned int
Return the mask unsigned instead, the same way term_attrs(), slk_attr()
and window.getattrs() already do. baudrate(), the macro's only other
user, really does return a status, so it keeps the ERR check; the macro
gains a comment saying it is only for such functions.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent bfc16a7 commit da6982e
3 files changed
Lines changed: 43 additions & 1 deletion
File tree
- Lib/test
- Misc/NEWS.d/next/Library
- Modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3242 | 3242 | | |
3243 | 3243 | | |
3244 | 3244 | | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
| 3258 | + | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
| 3271 | + | |
3245 | 3272 | | |
3246 | 3273 | | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5495 | 5495 | | |
5496 | 5496 | | |
5497 | 5497 | | |
| 5498 | + | |
| 5499 | + | |
| 5500 | + | |
| 5501 | + | |
5498 | 5502 | | |
5499 | 5503 | | |
5500 | 5504 | | |
| |||
7899 | 7903 | | |
7900 | 7904 | | |
7901 | 7905 | | |
7902 | | - | |
| 7906 | + | |
| 7907 | + | |
| 7908 | + | |
| 7909 | + | |
| 7910 | + | |
| 7911 | + | |
| 7912 | + | |
| 7913 | + | |
| 7914 | + | |
7903 | 7915 | | |
7904 | 7916 | | |
7905 | 7917 | | |
| |||
0 commit comments