]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-153009: Fix compilation of `curses` on platforms that define the `stdscr` macro...
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Sat, 4 Jul 2026 10:21:16 +0000 (12:21 +0200)
committerGitHub <noreply@github.com>
Sat, 4 Jul 2026 10:21:16 +0000 (12:21 +0200)
Include/py_curses.h
Misc/NEWS.d/next/Library/2026-07-04-11-26-24.gh-issue-153009.KGl-nQ.rst [new file with mode: 0644]
Modules/_cursesmodule.c

index 23e67c4e6e634d0331c857c61b1b7039f3fbca24..a5f5f3d76075827b360187ad5b2ed815fc6f3373 100644 (file)
@@ -96,7 +96,7 @@ typedef struct {
     SCREEN *screen;          /* NULL after the screen has been deleted */
     FILE *outfp;             /* owned output stream, or NULL */
     FILE *infp;              /* owned input stream, or NULL */
-    PyObject *stdscr;        /* the screen's standard window, or NULL */
+    PyObject *stdscr_win;    /* the screen's standard window, or NULL */
 } PyCursesScreenObject;
 
 #define PyCurses_CAPSULE_NAME "_curses._C_API"
diff --git a/Misc/NEWS.d/next/Library/2026-07-04-11-26-24.gh-issue-153009.KGl-nQ.rst b/Misc/NEWS.d/next/Library/2026-07-04-11-26-24.gh-issue-153009.KGl-nQ.rst
new file mode 100644 (file)
index 0000000..a8a74ca
--- /dev/null
@@ -0,0 +1,2 @@
+Fix compilation of :mod:`curses` on platforms that define the ``stdscr``
+macro. Patch by Bénédikt Tran.
index 03e399b252fcfb25898e5bfbc1b0c21d7d84faee..cc68a51f0bed93582481545fa650164f16eabfcc 100644 (file)
@@ -5125,7 +5125,7 @@ static PyType_Spec PyCursesWindow_Type_spec = {
 
 static PyObject *
 PyCursesScreen_New(cursesmodule_state *state, SCREEN *screen,
-                   FILE *outfp, FILE *infp, PyObject *stdscr)
+                   FILE *outfp, FILE *infp, PyObject *stdscr_win)
 {
     PyCursesScreenObject *so = PyObject_GC_New(PyCursesScreenObject,
                                                state->screen_type);
@@ -5135,7 +5135,7 @@ PyCursesScreen_New(cursesmodule_state *state, SCREEN *screen,
     so->screen = screen;
     so->outfp = outfp;
     so->infp = infp;
-    so->stdscr = Py_XNewRef(stdscr);
+    so->stdscr_win = Py_XNewRef(stdscr_win);
     PyObject_GC_Track((PyObject *)so);
     return (PyObject *)so;
 }
@@ -5169,17 +5169,17 @@ static PyObject *
 PyCursesScreen_get_stdscr(PyObject *self, void *Py_UNUSED(closure))
 {
     PyCursesScreenObject *so = _PyCursesScreenObject_CAST(self);
-    if (so->stdscr == NULL) {
+    if (so->stdscr_win == NULL) {
         Py_RETURN_NONE;
     }
-    return Py_NewRef(so->stdscr);
+    return Py_NewRef(so->stdscr_win);
 }
 
 static int
 PyCursesScreen_traverse(PyObject *self, visitproc visit, void *arg)
 {
     Py_VISIT(Py_TYPE(self));
-    Py_VISIT(_PyCursesScreenObject_CAST(self)->stdscr);
+    Py_VISIT(_PyCursesScreenObject_CAST(self)->stdscr_win);
     return 0;
 }
 
@@ -5194,10 +5194,10 @@ PyCursesScreen_clear(PyObject *self)
        detach it from its wrapper first: the wrapper must not delwin() a window
        that delscreen() frees.  Any further use of the wrapper operates on a
        NULL window and fails cleanly. */
-    if (so->stdscr != NULL) {
-        ((PyCursesWindowObject *)so->stdscr)->win = NULL;
+    if (so->stdscr_win != NULL) {
+        ((PyCursesWindowObject *)so->stdscr_win)->win = NULL;
     }
-    Py_CLEAR(so->stdscr);
+    Py_CLEAR(so->stdscr_win);
     return 0;
 }
 
@@ -6724,7 +6724,7 @@ _curses_newterm_impl(PyObject *module, const char *type, PyObject *fd,
         Py_DECREF(screenobj);
         return NULL;
     }
-    ((PyCursesScreenObject *)screenobj)->stdscr = Py_NewRef(win);
+    ((PyCursesScreenObject *)screenobj)->stdscr_win = Py_NewRef(win);
     Py_DECREF(win);
     Py_XSETREF(state->topscreen, Py_NewRef(screenobj));
     return screenobj;