Skip to content

gh-152503: Fix garbage text from curses wide-character cell reads#152505

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-cchar-init
Jun 29, 2026
Merged

gh-152503: Fix garbage text from curses wide-character cell reads#152505
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-cchar-init

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

window.in_wch(), window.in_wchstr() and window.getbkgrnd() read a cell into an uninitialized cchar_t and rely on the curses library leaving the text NUL-terminated — which ncurses does but X/Open does not require, so libraries such as NetBSD curses returned uninitialized bytes as wide characters (surfacing as ValueError for out-of-range code points).

Zero-initialize the cell buffers before the read (in_wch, getbkgrnd, in_wchstr) and default the getcchar() output to an empty string, since getcchar() need not write the text of an empty cell.

No-op on ncurses; test_curses keeps passing and stays refleak-clean.

🤖 Generated with Claude Code

window.in_wch(), window.in_wchstr() and window.getbkgrnd() read a cell
into an uninitialized cchar_t, relying on the curses library to leave the
text NUL-terminated -- which ncurses does but X/Open does not require, so
some libraries (such as NetBSD curses) returned uninitialized bytes as
wide characters.  Zero-initialize the cell buffers before the read and
default the getcchar() output to an empty string.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) June 29, 2026 11:42
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 29, 2026
@serhiy-storchaka serhiy-storchaka merged commit e7b21b6 into python:main Jun 29, 2026
106 of 108 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.15 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e7b21b66a4ddc0ed57f74972bfb7cf1b678fca0a 3.15

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e7b21b66a4ddc0ed57f74972bfb7cf1b678fca0a 3.14

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e7b21b66a4ddc0ed57f74972bfb7cf1b678fca0a 3.13

@serhiy-storchaka serhiy-storchaka removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 29, 2026
@serhiy-storchaka serhiy-storchaka removed their assignment Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant