GeezerVison is showing github.com — gh-151757: Support wide and combining characters in the curses module by serhiy-storchaka · Pull Request #151758 · python/cpython
Conversation
serhiy-storchaka
commented
Jun 19, 2026
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
The character-cell window methods now accept a full character cell -- a spacing character optionally followed by combining characters (up to CCHARW_MAX wide characters) -- in addition to a single int or byte character. This affects addch(), bkgd(), bkgdset(), border(), box(), echochar(), hline(), insch() and vline(), which dispatch to the ncursesw wide-character functions (wadd_wch(), wbkgrnd(), wborder_set(), wecho_wchar(), whline_set(), wins_wch(), wvline_set(), ...) when given a string. border() and box() cannot mix integer or byte characters with wide-string characters in a single call.
A cell is one spacing character optionally followed by combining characters, so an extra spacing or control character (for example "ab", an emoji ZWJ sequence, or an emoji with a skin-tone modifier) is rejected with ValueError rather than being silently truncated by setcchar(). A single control character is still accepted (curses applies its usual control processing, e.g. backspace, tab and carriage return).
Also added are the wide-character read methods window.get_wstr() and window.in_wstr(), the counterparts of window.getstr() and window.instr() that return a str rather than bytes, and the module functions curses.erasewchar(), curses.killwchar() and curses.wunctrl(), the wide-character counterparts of curses.erasechar(), curses.killchar() and curses.unctrl().
All of this is available only when built against the wide-character ncursesw library.
🤖 Generated with Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…module
The character-cell window methods now accept a full character cell -- a
spacing character optionally followed by combining characters (up to
CCHARW_MAX wide characters) -- in addition to a single int or byte
character. This affects addch(), bkgd(), bkgdset(), border(), box(),
echochar(), hline(), insch() and vline(); they dispatch to the ncursesw
wide-character functions (wadd_wch(), wbkgrnd(), wborder_set(),
wecho_wchar(), whline_set(), wins_wch(), wvline_set(), ...) when given a
string. border() and box() cannot mix integer or byte characters with
wide string characters in a single call. A cell is one spacing character
optionally followed by combining characters, so an extra spacing or
control character (such as "ab") is rejected with ValueError rather than
being silently truncated by setcchar().
Also add the wide-character read methods get_wstr() and in_wstr(), the
counterparts of getstr() and instr() that return a str rather than a
bytes object, and the module functions erasewchar(), killwchar() and
wunctrl(), the wide-character counterparts of erasechar(), killchar()
and unctrl().
All of this is available only when built against the wide-character
ncursesw library.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
AA-Turner
Awaiting requested review from AA-Turner
AA-Turner is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|