From: Serhiy Storchaka Date: Tue, 30 Jun 2026 09:09:09 +0000 (+0300) Subject: gh-152325: Gate curses.has_mouse() on the ncurses patch level (GH-152652) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11d42bd269788a0dd9ff954b63d7fd7139c3e46f;p=thirdparty%2FPython%2Fcpython.git gh-152325: Gate curses.has_mouse() on the ncurses patch level (GH-152652) has_mouse() was added to ncurses after the 5.7 release, but the binding guarded it only with NCURSES_MOUSE_VERSION, which 5.7 already defines, so the module failed to compile against ncurses 5.7 (such as the system curses on macOS). Gate it additionally on NCURSES_EXT_FUNCS, which holds the library's patch date. Co-authored-by: Claude Opus 4.8 --- diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst index b3341fb8629f..7178325e708b 100644 --- a/Doc/library/curses.rst +++ b/Doc/library/curses.rst @@ -465,6 +465,8 @@ Mouse Return ``True`` if the mouse driver has been successfully initialized. + Availability: ncurses 5.8 or later. + .. versionadded:: next diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index cbd452169684..dc373c8cef93 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -7041,6 +7041,8 @@ _curses_meta_impl(PyObject *module, int yes) } #ifdef NCURSES_MOUSE_VERSION +/* has_mouse() was added to ncurses after the 5.7 release. */ +#if defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081122 /*[clinic input] _curses.has_mouse @@ -7055,6 +7057,7 @@ _curses_has_mouse_impl(PyObject *module) return PyBool_FromLong(has_mouse()); } +#endif /* NCURSES_EXT_FUNCS >= 20081122 */ /*[clinic input] _curses.mouseinterval diff --git a/Modules/clinic/_cursesmodule.c.h b/Modules/clinic/_cursesmodule.c.h index 78619842f97f..e69be47549cf 100644 --- a/Modules/clinic/_cursesmodule.c.h +++ b/Modules/clinic/_cursesmodule.c.h @@ -4232,7 +4232,7 @@ exit: return return_value; } -#if defined(NCURSES_MOUSE_VERSION) +#if defined(NCURSES_MOUSE_VERSION) && (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081122) PyDoc_STRVAR(_curses_has_mouse__doc__, "has_mouse($module, /)\n" @@ -4252,7 +4252,7 @@ _curses_has_mouse(PyObject *module, PyObject *Py_UNUSED(ignored)) return _curses_has_mouse_impl(module); } -#endif /* defined(NCURSES_MOUSE_VERSION) */ +#endif /* defined(NCURSES_MOUSE_VERSION) && (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081122) */ #if defined(NCURSES_MOUSE_VERSION) @@ -6174,4 +6174,4 @@ _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored #ifndef _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF #define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF #endif /* !defined(_CURSES_ASSUME_DEFAULT_COLORS_METHODDEF) */ -/*[clinic end generated code: output=55829d2ef2b559a0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=809e4680d429b870 input=a9049054013a1b77]*/