Skip to content

[3.15] gh-153862: Fix curses window.inch() for non-ASCII characters on a wide build (GH-153863)#154116

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

[3.15] gh-153862: Fix curses window.inch() for non-ASCII characters on a wide build (GH-153863)#154116
serhiy-storchaka merged 1 commit into
python:3.15from
serhiy-storchaka:backport-3.15-curses-inch

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

Manual backport of #153863.

3.15 predates the 3.16 complexchar refactor, so the fix inlines getcchar() into a small helper instead of the curses_getcchar wrapper; the logic (recover the locale byte via wctob()) is unchanged.

Verified on a wide (HAVE_NCURSESW) build: test_curses passes, including test_read_from_window under ISO-8859-15 where (0xA4) exercises the fix.

… a wide build (pythonGH-153863)

On a wide build, winch() returns the low 8 bits of the character's code
point with no locale conversion, so inch()/mvinch() disagreed with instr()
for a non-ASCII character of an 8-bit locale ('€' under ISO-8859-15 gave
0xAC instead of 0xA4).  Re-encode the cell to its locale byte via wctob(),
as ncurses does for getbkgd().

(cherry picked from commit a83aaa9)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jul 19, 2026
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) July 19, 2026 12:19
@serhiy-storchaka
serhiy-storchaka merged commit 7d1b64b into python:3.15 Jul 19, 2026
67 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.
🐍🍒⛏🤖

@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 7d1b64bd9a07deb4ce20e0f3d1b07b0507c51431 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 7d1b64bd9a07deb4ce20e0f3d1b07b0507c51431 3.13

@serhiy-storchaka serhiy-storchaka removed needs backport to 3.14 bugs and security fixes needs backport to 3.13 bugs and security fixes labels Jul 19, 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