]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-152233: Add curses complexchar type and wide-character cell reads (GH-152250)
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 26 Jun 2026 10:49:17 +0000 (13:49 +0300)
committerGitHub <noreply@github.com>
Fri, 26 Jun 2026 10:49:17 +0000 (13:49 +0300)
commit8a01d28b7effa565c63047d3fe08ddc407db50e8
tree2a6fd2b5ab082d664751eb10a0e15e846baee33c
parent285d96dd784620fe8afb02688abe72a916555061
gh-152233: Add curses complexchar type and wide-character cell reads (GH-152250)

Add the immutable `curses.complexchar` type: a styled wide-character cell — a spacing character optionally followed by combining characters, plus attributes and a color pair. The color pair is stored separately rather than packed into a `chtype` via `COLOR_PAIR()`, so it is not limited to the values that fit alongside the attribute bits. `str(cc)` returns the text; the read-only `attr` and `pair` attributes return its rendition.

Add the window methods `in_wch()` and `getbkgrnd()` — the wide-character counterparts of `inch()` and `getbkgd()` — which return a `complexchar`. (`inch()`/`getbkgd()` can only return a packed `chtype`, so these fill a real gap; this resolves the long-standing gh-83395 request for `in_wch`.)

The existing character-cell methods (`addch`, `insch`, `echochar`, `bkgd`, `bkgdset`, `border`, `box`, `hline`, `vline`) now also accept a `complexchar`. A `complexchar` already carries its own rendition, so passing one together with an explicit `attr` argument raises `TypeError`.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Doc/library/curses.rst
Doc/whatsnew/3.16.rst
Include/internal/pycore_global_objects_fini_generated.h
Include/internal/pycore_global_strings.h
Include/internal/pycore_runtime_init_generated.h
Include/internal/pycore_unicodeobject_generated.h
Lib/test/test_curses.py
Misc/NEWS.d/next/Library/2026-06-25-22-41-49.gh-issue-152233.pEhm3q.rst [new file with mode: 0644]
Modules/_cursesmodule.c
Modules/clinic/_cursesmodule.c.h