gh-153862: Fix spurious color pair in curses window.inch() on a wide build#154703
Merged
serhiy-storchaka merged 2 commits intoJul 26, 2026
Conversation
… wide build winch() returns the whole code point, so inch() replacing only its low 8 bits left the high bits in the color field. Rebuild from getcchar()'s attributes and color pair. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka
enabled auto-merge (squash)
July 25, 2026 20:39
serhiy-storchaka
disabled auto-merge
July 26, 2026 04:57
On a wide build inch() derived its result from winch(), whose character is the whole code point rather than a locale byte, so a code point past 0xff overflowed into the color field and past 0xffff into the attribute bits. Read the cell with win_wch() and build the chtype from the locale byte plus the attributes and color pair reported by getcchar(). The character is 0 when it has no single-byte form; win_wch() and getcchar() failures now raise. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
|
GH-154720 is a backport of this pull request to the 3.15 branch. |
serhiy-storchaka
added a commit
that referenced
this pull request
Jul 26, 2026
…a wide build (GH-154703) (GH-154720) winch() returns the whole code point, so inch() replacing only its low 8 bits left the high bits in the color field. Rebuild from getcchar()'s attributes and color pair. (cherry picked from commit b618874) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * gh-153862: Suggest instr() for non-encodable characters read by inch() A character that does not fit in a single byte has a character byte of 0 in the value returned by inch(); document reading such characters with instr(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
GH-154732 is a backport of this pull request to the 3.14 branch. |
|
GH-154733 is a backport of this pull request to the 3.13 branch. |
serhiy-storchaka
added a commit
that referenced
this pull request
Jul 26, 2026
…a wide build (GH-154703) (GH-154733) winch() returns the whole code point, so inch() replacing only its low 8 bits left the high bits in the color field. Rebuild from getcchar()'s attributes and color pair. (cherry picked from commit b618874) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka
added a commit
that referenced
this pull request
Jul 26, 2026
…a wide build (GH-154703) (GH-154732) winch() returns the whole code point, so inch() replacing only its low 8 bits left the high bits in the color field. Rebuild from getcchar()'s attributes and color pair. (cherry picked from commit b618874) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
winch()returns the character's full code point, soinch()/mvinch()recovering the locale byte by replacing only its low 8 bits left a code point past0xffleaking into the color-pair field. Under ISO-8859-15,inch()of'€'returned0x20A4(the byte0xA4plus a spurious color pair 32) instead of0xA4.Rebuild the value from the attributes and color pair that
getcchar()reports separately.The test asserted only
inch() & A_CHARTEXT, masking the leaked bits; it now asserts the whole value.