Bug description:
window.addstr(y, x, s, attr) sets the window rendition to attr for the write and restores the previous one afterwards. Since 3.15 the restore is skipped when the write itself fails, so the window keeps the caller's attr and whatever the application had set with attrset() is gone. addnstr(), insstr() and insnstr() behave the same way.
import curses
def check(stdscr):
win = curses.newwin(2, 10, 0, 0)
win.attrset(curses.A_UNDERLINE)
try:
win.addstr(100, 0, 'x', curses.A_BOLD) # outside the window: raises
except curses.error:
pass
win.addstr(0, 0, 'y') # no attr argument
return win.inch(0, 0) & curses.A_ATTRIBUTES
print('want', hex(curses.A_UNDERLINE), 'got', hex(curses.wrapper(check)))
$ python3.14 repro.py
want 0x20000 got 0x20000
$ ./python repro.py
want 0x20000 got 0x200000
Expected: got 0x20000 on both, the rendition the caller set with attrset().
This changed in 30dde1e (gh-133579), which moved the restore below a new early return on the error path.
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug description:
window.addstr(y, x, s, attr)sets the window rendition to attr for the write and restores the previous one afterwards. Since 3.15 the restore is skipped when the write itself fails, so the window keeps the caller's attr and whatever the application had set withattrset()is gone.addnstr(),insstr()andinsnstr()behave the same way.Expected:
got 0x20000on both, the rendition the caller set withattrset().This changed in 30dde1e (gh-133579), which moved the restore below a new early return on the error path.
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Linux
Linked PRs