Skip to content

Commit 7ad8bc2

Browse files
[3.14] gh-152502: Detect optional curses functions with configure probes (GH-152504) (GH-152589) (GH-152603)
set_escdelay(), set_tabsize() and the ESCDELAY and TABSIZE variables were gated only by the ncurses-specific NCURSES_EXT_FUNCS macro, which excluded them when building against other curses implementations such as NetBSD curses even when they provided them. Detect each with a configure capability probe and gate on HAVE_CURSES_*. (cherry picked from commit 0635e55) (cherry picked from commit 2a4ffa6) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6f6256f commit 7ad8bc2

6 files changed

Lines changed: 302 additions & 15 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The :mod:`curses` module now detects ``set_escdelay()``, ``set_tabsize()`` and
2+
the ``ESCDELAY`` and ``TABSIZE`` variables with :program:`configure` capability
3+
probes instead of the ncurses-specific ``NCURSES_EXT_FUNCS`` macro, so they are
4+
exposed when building against other curses implementations such as NetBSD curses
5+
that provide them.

Modules/_cursesmodule.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3736,9 +3736,7 @@ _curses_setupterm_impl(PyObject *module, const char *term, int fd)
37363736
Py_RETURN_NONE;
37373737
}
37383738

3739-
#if defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102
3740-
// https://invisible-island.net/ncurses/NEWS.html#index-t20080119
3741-
3739+
#ifdef HAVE_CURSES_ESCDELAY
37423740
/*[clinic input]
37433741
_curses.get_escdelay
37443742
@@ -3755,6 +3753,9 @@ _curses_get_escdelay_impl(PyObject *module)
37553753
{
37563754
return PyLong_FromLong(ESCDELAY);
37573755
}
3756+
#endif /* HAVE_CURSES_ESCDELAY */
3757+
3758+
#ifdef HAVE_CURSES_SET_ESCDELAY
37583759
/*[clinic input]
37593760
_curses.set_escdelay
37603761
ms: int
@@ -3779,7 +3780,9 @@ _curses_set_escdelay_impl(PyObject *module, int ms)
37793780

37803781
return PyCursesCheckERR(module, set_escdelay(ms), "set_escdelay");
37813782
}
3783+
#endif /* HAVE_CURSES_SET_ESCDELAY */
37823784

3785+
#ifdef HAVE_CURSES_TABSIZE
37833786
/*[clinic input]
37843787
_curses.get_tabsize
37853788
@@ -3795,6 +3798,9 @@ _curses_get_tabsize_impl(PyObject *module)
37953798
{
37963799
return PyLong_FromLong(TABSIZE);
37973800
}
3801+
#endif /* HAVE_CURSES_TABSIZE */
3802+
3803+
#ifdef HAVE_CURSES_SET_TABSIZE
37983804
/*[clinic input]
37993805
_curses.set_tabsize
38003806
size: int
@@ -3818,7 +3824,7 @@ _curses_set_tabsize_impl(PyObject *module, int size)
38183824

38193825
return PyCursesCheckERR(module, set_tabsize(size), "set_tabsize");
38203826
}
3821-
#endif
3827+
#endif /* HAVE_CURSES_SET_TABSIZE */
38223828

38233829
/*[clinic input]
38243830
_curses.intrflush
@@ -5075,10 +5081,8 @@ static PyMethodDef cursesmodule_methods[] = {
50755081
_CURSES_RESIZETERM_METHODDEF
50765082
_CURSES_RESIZE_TERM_METHODDEF
50775083
_CURSES_SAVETTY_METHODDEF
5078-
#if defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102
50795084
_CURSES_GET_ESCDELAY_METHODDEF
50805085
_CURSES_SET_ESCDELAY_METHODDEF
5081-
#endif
50825086
_CURSES_GET_TABSIZE_METHODDEF
50835087
_CURSES_SET_TABSIZE_METHODDEF
50845088
_CURSES_SETSYX_METHODDEF

Modules/clinic/_cursesmodule.c.h

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure

Lines changed: 238 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)