Skip to content

gh-154070: Build the curses module wide by capability, not by name#154071

Open
serhiy-storchaka wants to merge 4 commits into
python:mainfrom
serhiy-storchaka:curses-wide-by-capability
Open

gh-154070: Build the curses module wide by capability, not by name#154071
serhiy-storchaka wants to merge 4 commits into
python:mainfrom
serhiy-storchaka:curses-wide-by-capability

Conversation

@serhiy-storchaka

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

Copy link
Copy Markdown
Member

configure chose wide vs narrow (HAVE_NCURSESW) by the pkg-config namencursesw wide, ncurses narrow — but wide support is a property of the library, not its name. A widec-built ncurses that keeps the plain libncurses/ncurses.pc name (pkgsrc on NetBSD/illumos, macOS system ncurses) was built narrow, losing the wide API and limiting addch()/getch()/inch() to ASCII in UTF-8 locales.

This runs the existing wide-API probe (setcchar()/add_wch(), added for the native curses backend in gh-136687) for the ncurses/auto backends too, defining HAVE_NCURSESW by capability. On macOS, where the locale is UTF-8, this turns a nearly unusable narrow build into a wide one.

Validated: Linux ncursesw stays wide and narrow ncurses/curses stay narrow; OpenIndiana and NetBSD pkgsrc ncurses go narrow → wide (NetBSD test_curses 162 run / 1 skip SUCCESS). macOS cannot be tested locally — the buildbots will.

configure built the module wide (HAVE_NCURSESW) only for a backend named
ncursesw.  Probe for the wide API in the ncurses and auto backends too, so
a widec-built ncurses keeping the plain name (pkgsrc, macOS) is built wide.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
serhiy-storchaka and others added 3 commits July 22, 2026 20:13
…r build

The wide-character probe ran inside a nested WITH_SAVE_ENV, whose single
CPPFLAGS save slot is not reentrant, so the outer restore leaked
$CURSES_CFLAGS and $PANEL_CFLAGS (-D_XOPEN_SOURCE=600) into
CONFIGURE_CPPFLAGS and thus into every translation unit, producing a
'_XOPEN_SOURCE' redefined warning against pyconfig.h on every file.

Save and restore CPPFLAGS with a dedicated variable around the probe.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant