Skip to content

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

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

[3.14] gh-153864: Fix curses window.insch() for non-ASCII characters on a wide build (GH-153865)#154152
serhiy-storchaka merged 1 commit into
python:3.14from
serhiy-storchaka:backport-3.14-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.14 predates the 3.15 error-handling refactor, so the wide-character path is written in 3.14's addch() idiom: setcchar(..., PAIR_NUMBER(...), NULL) + wins_wch/mvwins_wch, returning through PyCursesCheckERR_ForWin().

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 merged commit 8b5f1c2 into python:3.14 Jul 19, 2026
49 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the backport-3.14-curses-insch branch July 19, 2026 19:28
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