Skip to content

Commit d608eb9

Browse files
[3.13] gh-152502: Detect optional curses functions with configure probes (GH-152504) (GH-152589) (GH-152602)
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 b066cd5 commit d608eb9

6 files changed

Lines changed: 294 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
@@ -3479,9 +3479,7 @@ _curses_setupterm_impl(PyObject *module, const char *term, int fd)
34793479
Py_RETURN_NONE;
34803480
}
34813481

3482-
#if defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102
3483-
// https://invisible-island.net/ncurses/NEWS.html#index-t20080119
3484-
3482+
#ifdef HAVE_CURSES_ESCDELAY
34853483
/*[clinic input]
34863484
_curses.get_escdelay
34873485
@@ -3498,6 +3496,9 @@ _curses_get_escdelay_impl(PyObject *module)
34983496
{
34993497
return PyLong_FromLong(ESCDELAY);
35003498
}
3499+
#endif /* HAVE_CURSES_ESCDELAY */
3500+
3501+
#ifdef HAVE_CURSES_SET_ESCDELAY
35013502
/*[clinic input]
35023503
_curses.set_escdelay
35033504
ms: int
@@ -3522,7 +3523,9 @@ _curses_set_escdelay_impl(PyObject *module, int ms)
35223523

35233524
return PyCursesCheckERR(set_escdelay(ms), "set_escdelay");
35243525
}
3526+
#endif /* HAVE_CURSES_SET_ESCDELAY */
35253527

3528+
#ifdef HAVE_CURSES_TABSIZE
35263529
/*[clinic input]
35273530
_curses.get_tabsize
35283531
@@ -3538,6 +3541,9 @@ _curses_get_tabsize_impl(PyObject *module)
35383541
{
35393542
return PyLong_FromLong(TABSIZE);
35403543
}
3544+
#endif /* HAVE_CURSES_TABSIZE */
3545+
3546+
#ifdef HAVE_CURSES_SET_TABSIZE
35413547
/*[clinic input]
35423548
_curses.set_tabsize
35433549
size: int
@@ -3561,7 +3567,7 @@ _curses_set_tabsize_impl(PyObject *module, int size)
35613567

35623568
return PyCursesCheckERR(set_tabsize(size), "set_tabsize");
35633569
}
3564-
#endif
3570+
#endif /* HAVE_CURSES_SET_TABSIZE */
35653571

35663572
/*[clinic input]
35673573
_curses.intrflush
@@ -4766,10 +4772,8 @@ static PyMethodDef PyCurses_methods[] = {
47664772
_CURSES_RESIZETERM_METHODDEF
47674773
_CURSES_RESIZE_TERM_METHODDEF
47684774
_CURSES_SAVETTY_METHODDEF
4769-
#if defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102
47704775
_CURSES_GET_ESCDELAY_METHODDEF
47714776
_CURSES_SET_ESCDELAY_METHODDEF
4772-
#endif
47734777
_CURSES_GET_TABSIZE_METHODDEF
47744778
_CURSES_SET_TABSIZE_METHODDEF
47754779
_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: 230 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)