Skip to content

[3.13] gh-153864: Fix curses window.insch() for non-ASCII characters on a wide build (GH-153865)#154154

Merged
serhiy-storchaka merged 1 commit into
python:3.13from
serhiy-storchaka:backport-3.13-curses-insch
Jul 19, 2026
Merged

[3.13] gh-153864: Fix curses window.insch() for non-ASCII characters on a wide build (GH-153865)#154154
serhiy-storchaka merged 1 commit into
python:3.13from
serhiy-storchaka:backport-3.13-curses-insch

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 19, 2026

Copy link
Copy Markdown
Member

Manual backport of #153865; the automatic backport hit a conflict.

3.13 predates the 3.15 error-handling refactor, so the wide-character path is written in 3.13's addch() idiom: setcchar(..., PAIR_NUMBER(...), NULL) + wins_wch/mvwins_wch, returning through the module-level PyCursesCheckERR().

Verified on a wide (HAVE_NCURSESW) build: test_output_character passes under ISO-8859-15 where (0xA4) exercises the fix, and the full test_curses is green there.

…cters on a wide build (pythonGH-153865)

On a wide build, winsch() does not locale-decode a byte above 127, unlike
waddch(), so insch()/mvinsch() stored the wrong character for a non-ASCII
byte of an 8-bit locale ('€' 0xA4 under ISO-8859-15 became U+00A4 '¤').
Decode the byte with btowc() and insert it as a wide character, as addch()
effectively does.

(cherry picked from commit 223cbff)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) July 19, 2026 15:00
@serhiy-storchaka
serhiy-storchaka merged commit fb9a98a into python:3.13 Jul 19, 2026
42 checks passed
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