[Python-checkins] gh-98724: Fix warnings on Py_SETREF() usage (#99781)

vstinner webhook-mailer at python.org
Fri Nov 25 18:30:42 EST 2022


https://github.com/python/cpython/commit/5556d3e02ca841b82b1eb42cc3974e0a3bbffaac
commit: 5556d3e02ca841b82b1eb42cc3974e0a3bbffaac
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-11-26T00:30:37+01:00
summary:

gh-98724: Fix warnings on Py_SETREF() usage (#99781)

Cast argument to the expected type.

files:
M Modules/_curses_panel.c
M Objects/longobject.c
M Objects/typeobject.c

diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c
index cd408d6aa359..2144345de01b 100644
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -424,7 +424,7 @@ _curses_panel_panel_replace_impl(PyCursesPanelObject *self,
         PyErr_SetString(state->PyCursesError, "replace_panel() returned ERR");
         return NULL;
     }
-    Py_SETREF(po->wo, Py_NewRef(win));
+    Py_SETREF(po->wo, (PyCursesWindowObject*)Py_NewRef(win));
     Py_RETURN_NONE;
 }
 
diff --git a/Objects/longobject.c b/Objects/longobject.c
index f4bd981e4b98..c84b4d3f316d 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -4775,7 +4775,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
          * because we're primarily trying to cut overhead for small powers.
          */
         assert(bi);  /* else there is no significant bit */
-        Py_SETREF(z, Py_NewRef(a));
+        Py_SETREF(z, (PyLongObject*)Py_NewRef(a));
         for (bit = 2; ; bit <<= 1) {
             if (bit > bi) { /* found the first bit */
                 assert((bi & bit) == 0);
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index ad8a936fa7ce..b993aa405f6b 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -9593,7 +9593,7 @@ super_init_impl(PyObject *self, PyTypeObject *type, PyObject *obj) {
             return -1;
         Py_INCREF(obj);
     }
-    Py_XSETREF(su->type, Py_NewRef(type));
+    Py_XSETREF(su->type, (PyTypeObject*)Py_NewRef(type));
     Py_XSETREF(su->obj, obj);
     Py_XSETREF(su->obj_type, obj_type);
     return 0;



More information about the Python-checkins mailing list