]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-152325: Gate curses.has_mouse() on the ncurses patch level (GH-152652)
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 30 Jun 2026 09:09:09 +0000 (12:09 +0300)
committerGitHub <noreply@github.com>
Tue, 30 Jun 2026 09:09:09 +0000 (09:09 +0000)
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 <noreply@anthropic.com>
Doc/library/curses.rst
Modules/_cursesmodule.c
Modules/clinic/_cursesmodule.c.h

index b3341fb8629f4cad91587aff926c3c262963f40a..7178325e708bc12e33dc5f81a3cbe0aaabd25eca 100644 (file)
@@ -465,6 +465,8 @@ Mouse
 
    Return ``True`` if the mouse driver has been successfully initialized.
 
+   Availability: ncurses 5.8 or later.
+
    .. versionadded:: next
 
 
index cbd4521696847028e25e3ef17b62d74670c51094..dc373c8cef932c19c0253c61b625b878b8933770 100644 (file)
@@ -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
index 78619842f97fd778be2023949a56614fac4bef0e..e69be47549cf652c30e6541caf3658d9a7e8879d 100644 (file)
@@ -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]*/