Skip to content

gh-152233: Make the curses cell API work without ncursesw#152466

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

gh-152233: Make the curses cell API work without ncursesw#152466
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-narrow-cells

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Make complexchar, complexstr and the cell read methods in_wch, in_wchstr, in_wstr and getbkgrnd work whether or not Python was built against a wide-character (ncursesw) library, so the same code runs on both builds.

When ncursesw is absent a cell is backed by a chtype instead of a cchar_t: it holds a single character, encodable as one byte in the window's encoding (so only 8-bit locales are supported), with the color pair limited to the color_pair() range. get_wch, get_wstr, erasewchar, killwchar and wunctrl stay wide-only (they have no narrow counterpart with the same return type).

Tested on both a wide (-lncursesw) and a narrow (-lncurses) build of test_curses under en_US.UTF-8, en_US.ISO-8859-15 and uk_UA.KOI8-U.

Back complexchar, complexstr and the cell read methods (in_wch,
in_wchstr, in_wstr, getbkgrnd) with a chtype instead of a cchar_t when
ncursesw is absent, so the same code works on both builds.  A narrow
build is limited to one character per cell, encodable as a single byte in
the window's encoding (8-bit locales), with the color pair limited to the
color_pair() range.

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

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33341197 | 📁 Comparing 4dd24a5 against main (46d1809)

  🔍 Preview build  

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

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) June 28, 2026 05:08
@serhiy-storchaka serhiy-storchaka merged commit 95bfaff into python:main Jun 28, 2026
55 of 56 checks passed
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