]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-152233: Add curses complexstr type and wide-character cell-array methods (GH-152262)
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 26 Jun 2026 11:37:30 +0000 (14:37 +0300)
committerGitHub <noreply@github.com>
Fri, 26 Jun 2026 11:37:30 +0000 (14:37 +0300)
commit55fe0e64f3a50e5f292198192a07a3f0743df362
treed00bed45f0007e24968c89eabeede09b95b48278
parent8eb6fb0294956f3aaca0ace76b5ee77bd84b03a0
gh-152233: Add curses complexstr type and wide-character cell-array methods (GH-152262)

Add the immutable curses.complexstr type, an array of styled wide-character
cells -- the string counterpart of complexchar.  It is constructible from an
iterable of cells (each a complexchar or a str) or from a string split into
cells, with optional attr and pair applied to every cell.  It is an immutable
sequence (indexing yields a complexchar, slicing and concatenation yield a
complexstr), is hashable, and str() returns its cells' text.

Add the window method in_wchstr(), the wide-character counterpart of instr()
and in_wstr() that keeps each cell's attributes and color pair instead of
stripping them; it returns a complexstr.

The methods addstr(), addnstr(), insstr() and insnstr() now also accept a
complexstr, so a run read with in_wchstr() can be written back unchanged.  The
cells carry their own rendition, so combining one with an explicit attr raises
TypeError.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Doc/library/curses.rst
Doc/whatsnew/3.16.rst
Lib/test/test_curses.py
Misc/NEWS.d/next/Library/2026-06-26-11-20-00.gh-issue-152233.Kp7mQ2.rst [new file with mode: 0644]
Modules/_cursesmodule.c
Modules/clinic/_cursesmodule.c.h