Skip to content

gh-153395: Accept curses.complexchar in curses.ascii predicates and conversions#153396

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-ascii-complexchar
Jul 17, 2026
Merged

gh-153395: Accept curses.complexchar in curses.ascii predicates and conversions#153396
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-ascii-complexchar

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

The curses.ascii predicates and the ctrl() and unctrl() functions now accept a curses.complexchar (the character-cell type added in gh-151757), classifying it by its single character. A complexchar that holds combining characters is not a single character and so matches no class.

ctrl() now returns a non-ASCII argument unchanged instead of masking it to a control character. There is no control character outside ASCII, and for many keys ctrl() on the real terminal is already a no-op (1, ', .) or emits irreproducible codes (KEY_BACKSPACE, KEY_RESIZE), so masking a non-ASCII code to a control character was meaningless.

ascii(), alt() and ismeta() are left unchanged: they remain meaningful only for 8-bit codes, as they already were for most non-ASCII characters.

… and conversions

The curses.ascii predicates and the ctrl() and unctrl() functions now accept
a curses.complexchar, classifying it by its single character.  ctrl() now
returns a non-ASCII argument unchanged instead of masking it to a control
character.

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

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33509404 | 📁 Comparing 25feef4 against main (f3fd9dc)

  🔍 Preview build  

2 files changed
± library/curses.ascii.html
± whatsnew/changelog.html

@serhiy-storchaka
serhiy-storchaka merged commit abdd7ae into python:main Jul 17, 2026
53 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the curses-ascii-complexchar branch July 17, 2026 08:10
@zware

zware commented Jul 18, 2026

Copy link
Copy Markdown
Member

It looks like this broke a few builds, notably Debian root, M1 macOS, and intel macOS. The latter two make me suspect that we're not installing curses on the GHA macOS builders :)

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Thanks @zware. Those builders do have curses — they're narrow builds, and under a UTF-8 locale complexchar('\xe9') raises OverflowError (no single-byte cell), which the test didn't catch. Fixed in #154005.

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.

2 participants