GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — curses: detect optional functions with configure probes instead of assuming ncurses · Issue #152502 · python/cpython

curses: detect optional functions with configure probes instead of assuming ncurses #152502

New issue
Copy link
New issue
Copy link
Closed
Closed
curses: detect optional functions with configure probes instead of assuming ncurses#152502
Copy link
Labels
buildThe build process and cross-buildThe build process and cross-buildextension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement

Description

@serhiy-storchaka
serhiy-storchaka
opened on Jun 28, 2026
Issue body actions

Several functions in Modules/_cursesmodule.c are called unconditionally or gated only by the ncurses-specific NCURSES_EXT_FUNCS macro. Both break building or using the module against curses implementations other than ncursesw — narrow (non-wide) ncurses, and third-party curses such as NetBSD curses — even when the library provides the function.

Unconditionally-called functions that aren't universally present (no HAVE_CURSES_* guard, so a library lacking them fails to link):

  • scr_dump/scr_restore/scr_init/scr_set — the whole family is absent from NetBSD curses.
  • key_defined — absent from NetBSD curses (which has define_key/keyok).
  • term_attrs — the X/Open wide attribute query, present only in libncursesw, so missing from a narrow -lncurses build.

Functions gated by NCURSES_EXT_FUNCS that NetBSD implements without defining that macro, so the module silently drops them:

  • define_key, keyok, set_escdelay, set_tabsize, get_escdelay, get_tabsize.

Proposed change: detect each with a configure capability probe and gate on HAVE_CURSES_*.

  • PY_CHECK_CURSES_FUNC probes for scr_dump (one probe gates the inseparable family), key_defined, term_attrs, define_key, keyok, set_escdelay, set_tabsize.
  • get_escdelay/get_tabsize read the ESCDELAY/TABSIZE variables, which some libraries declare as extern int rather than macros, so a function probe doesn't fit. Add a small PY_CHECK_CURSES_VAR macro (tests that int x = ESCDELAY; compiles) and gate the getters on HAVE_CURSES_ESCDELAY/HAVE_CURSES_TABSIZE.

None of these are in X/Open Curses; they are ncurses extensions (NetBSD provides compatible ones), so capability-gating is the correct treatment, and a probe is more portable than conditioning on NCURSES_VERSION.

No behaviour change on standard ncursesw (all macros defined). test_curses passes and is refleak-clean on ncursesw, narrow ncurses, and NetBSD curses, under UTF-8 and 8-bit locales. test_env_queries calls curses.term_attrs() unconditionally and needs a hasattr guard for the narrow case.

Linked PRs

  • gh-152502: Detect optional curses functions with configure probes #152504
  • [3.15] gh-152502: Detect optional curses functions with configure probes (GH-152504) #152589
  • [3.13] gh-152502: Detect optional curses functions with configure probes (GH-152504) (GH-152589) #152602
  • [3.14] gh-152502: Detect optional curses functions with configure probes (GH-152504) (GH-152589) #152603
  • gh-152502: Detect the curses mouse interface and is_* methods portably #152705
  • [3.15] gh-152502: Detect the curses mouse interface portably (GH-152705) #152707
  • [3.14] gh-152502: Detect the curses mouse interface portably (GH-152705) #152734
  • [3.13] gh-152502: Detect the curses mouse interface portably (GH-152705) #152735

Activity

  1. picnixz
    added
    type-featureA feature request or enhancementA feature request or enhancement
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    buildThe build process and cross-buildThe build process and cross-build
    on Jun 28, 2026
  2. picnixz
    added this to Curses issueson Jun 28, 2026
  3. serhiy-storchaka
    added 3 commits that reference this issue on Jun 29, 2026

    gh-152502: Detect optional curses functions with configure probes (GH…

    0635e55

    [3.15] pythongh-152502: Detect optional curses functions with configu…

    9a38a1e

    [3.15] gh-152502: Detect optional curses functions with configure pro…

    2a4ffa6
  4. serhiy-storchaka
    closed this as completedon Jun 29, 2026
  5. github-project-automation
    moved this to Done in Curses issueson Jun 29, 2026
  6. serhiy-storchaka
    added 2 commits that reference this issue on Jun 29, 2026

    [3.14] gh-152502: Detect optional curses functions with configure pro…

    7ad8bc2

    [3.13] gh-152502: Detect optional curses functions with configure pro…

    d608eb9
  7. serhiy-storchaka commented on Jun 30, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Jun 30, 2026
    MemberAuthor
    More actions

    Reopening: the curses mouse interface (getmouse/ungetmouse/mousemask/mouseinterval/has_mouse/wenclose/wmouse_trafo/mouse_trafo plus the BUTTON* constants) is gated only by the ncurses-specific NCURSES_MOUSE_VERSION macro, so it is dropped on NetBSD curses even though that library provides the whole API. Same treatment as the rest of this issue: gate on configure capability probes (getmouse, has_mouse) and on the presence of the BUTTON* macros instead of NCURSES_MOUSE_VERSION.

  8. serhiy-storchaka
    reopened this on Jun 30, 2026
  9. serhiy-storchaka
    added 4 commits that reference this issue on Jun 30, 2026

    gh-152502: Detect the curses mouse interface and is_* methods portably (

    7bbea4f

    [3.15] gh-152502: Detect the curses mouse interface portably (GH-152705…

    83391ce

    [3.13] gh-152502: Detect the curses mouse interface portably (GH-152705…

    79d2264

    [3.14] gh-152502: Detect the curses mouse interface portably (GH-152705…

    51cacbe
  10. serhiy-storchaka
    closed this as completedon Jul 1, 2026
  11. maurycy
    added a commit that references this issue on Jul 1, 2026

    Merge branch 'main' into maurycy/bye-abba

    da7d768
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildThe build process and cross-buildextension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • Curses issues
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.