Skip to content

gh-152233: Add curses complexstr type and wide-character cell-array methods#152262

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-complexstr
Jun 26, 2026
Merged

gh-152233: Add curses complexstr type and wide-character cell-array methods#152262
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-complexstr

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Add the immutable curses.complexstr type, an array of styled wide-character cells -- the string counterpart of complexchar (as str is to a single character). 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.

This is the second and final part of the cchar_t API (gh-152233); the first (GH-152250) added the single-cell complexchar type.

…rray methods

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.

This is the second step of the cchar_t API (cell arrays), after the single-cell
complexchar type.

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

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33322508 | 📁 Comparing 6efe2c5 against main (8a01d28)

  🔍 Preview build  

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

@serhiy-storchaka serhiy-storchaka merged commit 55fe0e6 into python:main Jun 26, 2026
56 checks passed
@serhiy-storchaka serhiy-storchaka deleted the curses-complexstr branch June 26, 2026 11:37
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.

1 participant