Skip to content

gh-133031: Support the full Unicode range in curses.textpad.Textbox#152482

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-textpad-utf8
Jun 28, 2026
Merged

gh-133031: Support the full Unicode range in curses.textpad.Textbox#152482
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-textpad-utf8

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Follow-up to #152451 (which fixed 8-bit non-ASCII handling).

curses.textpad.Textbox now reads input with get_wch() and the window back with in_wch(), so the full Unicode range -- including combining characters -- is entered and read back when curses is built with wide-character support.

Because those methods are now available on every build, the widget uses a single code path: without wide-character support a cell holds a single byte, so there it stays limited to an 8-bit locale encoding.

edit() passes non-ASCII characters to validate() and the command dispatch as strings, keeping ASCII characters and key codes as integers so existing validators keep working.

Verified on both wide (UTF-8) and narrow (ISO-8859-15, KOI8-U) builds.

🤖 Generated with Claude Code

…tbox

Read input with get_wch() and the window back with in_wch(), so combining
characters and characters outside the locale encoding now work where curses has
wide-character support.

edit() passes non-ASCII characters to validate() as strings, keeping ASCII and
key codes as integers so existing validators keep working.

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

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33342946 | 📁 Comparing 3f93eb5 against main (65585ca)

  🔍 Preview build  

3 files changed
± library/curses.html
± whatsnew/3.16.html
± whatsnew/changelog.html

@serhiy-storchaka serhiy-storchaka merged commit 499d31f into python:main Jun 28, 2026
52 of 53 checks passed
@serhiy-storchaka serhiy-storchaka deleted the curses-textpad-utf8 branch June 28, 2026 12:49
@hugovk

hugovk commented Jun 29, 2026

Copy link
Copy Markdown
Member

Looks like this is failing on the ARM64 MacOS M1 NoGIL 3.x buildbot, for example:

======================================================================
ERROR: test_textbox_edit_wide (test.test_curses.TestCurses.test_textbox_edit_wide) (ch='é')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/test_curses.py", line 2354, in test_textbox_edit_wide
    curses.unget_wch(c)
    ~~~~~~~~~~~~~~~~^^^
OverflowError: character does not fit in a single byte

https://buildbot.python.org/#/builders/1270/builds/7928

And likely some of the other buildbot failures: https://buildbot.python.org/#/release_status

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Thanks. Should be fixed in #152592.

@encukou

encukou commented Jul 1, 2026

Copy link
Copy Markdown
Member

The failure is still there: https://buildbot.python.org/#/builders/1270/builds/7968

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.

3 participants