https://github.com/python/cpython/commit/11d42bd269788a0dd9ff954b63d7fd7139c3e46f
commit: 11d42bd269788a0dd9ff954b63d7fd7139c3e46f
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-06-30T09:09:09Z
summary:

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 <[email protected]>

files:
M Doc/library/curses.rst
M Modules/_cursesmodule.c
M Modules/clinic/_cursesmodule.c.h

diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst
index b3341fb8629f4c..7178325e708bc1 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 cbd45216968470..dc373c8cef932c 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 78619842f97fd7..e69be47549cf65 100644
--- a/Modules/clinic/_cursesmodule.c.h
+++ b/Modules/clinic/_cursesmodule.c.h
@@ -4232,7 +4232,7 @@ _curses_meta(PyObject *module, PyObject *arg)
     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]*/

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to