Skip to content

gh-154055: Gate optional curses functions absent on old SVr4 curses#154057

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-svr4-gating
Jul 19, 2026
Merged

gh-154055: Gate optional curses functions absent on old SVr4 curses#154057
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:curses-svr4-gating

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Modules/_cursesmodule.c used several optional functions unconditionally, so the module failed to build against a limited curses such as the native SVr4 curses of illumos/Solaris. Probe and #ifdef-gate them, matching how the other optional functions (is_pad, resizeterm, …) are already handled:

  • the X/Open attr_t functions behind window.attr_get/attr_set/attr_on/attr_off/color_set,
  • the soft-label attribute functions slk_attr_on/slk_attr_off/slk_attr_set/slk_color,
  • scr_set() — probed separately from scr_dump/scr_restore/scr_init, which SVr4 has without it.

Two related fixes:

  • update_lines_cols() was compiled only under HAVE_CURSES_RESIZETERM/HAVE_CURSES_RESIZE_TERM but is used unconditionally (e.g. by set_term()), so a curses without resizeterm() failed to link.
  • On Solaris/illumos, define _BOOL (and include <stdbool.h>) so the SVr4 <curses.h> typedef char bool does not clash with C's bool.

test.test_curses skips or guards the tests that use the now-optional functions (splitting test_attributes so its chtype-based part still runs), and treats the native curses of NetBSD and illumos/Solaris as having a broken newterm() — they crash on repeated newterm()/delscreen(), like ncurses before 6.5.

Verified: no change on ncursesw (all present); on illumos SVr4 --with-curses=curses now builds, imports, and runs test_curses without crashing (remaining failures are SVr4 behavioural divergences).

…rses

Build hygiene so the curses modules build against a limited curses (e.g. the
native SVr4 curses of illumos/Solaris), matching how other optional functions
are already gated:

* Probe and #ifdef-gate the X/Open attr_t functions (window.attr_get/attr_set/
  attr_on/attr_off/color_set), the soft-label attribute functions
  (slk_attr_on/off/set, slk_color) and scr_set(); scr_set is probed separately
  from the scr_dump family, which SVr4 has without it.
* Stop gating update_lines_cols() on resizeterm(): it only reads LINES/COLS and
  is used unconditionally (e.g. by set_term()), so a build without resizeterm()
  failed to link.
* On Solaris/illumos define _BOOL (and include <stdbool.h>) so the SVr4
  <curses.h> "typedef char bool" does not clash with C's bool.

test.test_curses: skip or guard the tests that use the now-optional functions,
split test_attributes so its chtype-based part still runs, and treat the native
curses of NetBSD and illumos/Solaris as having broken newterm() (they crash on
repeated newterm()/delscreen(), like ncurses before 6.5).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka
serhiy-storchaka merged commit 104c397 into python:main Jul 19, 2026
57 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the curses-svr4-gating branch July 19, 2026 12:26
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