Skip to content

gh-155974: Restore the window attributes when a curses write fails - #155975

Open
fedonman wants to merge 1 commit into
python:mainfrom
fedonman:fix-curses-addstr-attr-restore
Open

gh-155974: Restore the window attributes when a curses write fails#155975
fedonman wants to merge 1 commit into
python:mainfrom
fedonman:fix-curses-addstr-attr-restore

Conversation

@fedonman

@fedonman fedonman commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

addstr(), addnstr(), insstr() and insnstr() now restore the window rendition before reporting a failed write, so a failure no longer leaves the caller's attr applied. A wattrset() failure is still reported when the write itself succeeded.

$ ./python -m test test_curses -u curses -v -m test_output_string_attr_restored
test_output_string_attr_restored (test.test_curses.TestCurses.test_output_string_attr_restored) ... ok
$ ./python -m test test_curses -u curses
Total tests: run=172 skipped=3
Result: SUCCESS

addstr(), addnstr(), insstr() and insnstr() set the window rendition to
the caller's attr, write, then restore the previous rendition.  Since
30dde1e the restore sits below an early return taken when the write
fails, so a failed write leaves the caller's attr on the window and
drops whatever the application had set with attrset().

Restore the rendition first and report the write error afterwards.  A
wattrset() failure is still reported when the write itself succeeded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant