summaryrefslogtreecommitdiff
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-16 18:34:24 +0100
committerGitHub <noreply@github.com>2022-11-16 18:34:24 +0100
commit8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b (patch)
tree510409237622aa30dfc6833602bdde97c578f2bb /Objects/typeobject.c
parent19c1462e8dca3319c8290e2edcce482bd18cb018 (diff)
downloadcpython-git-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.tar.gz
gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 675d6d874d..1e58d32f49 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5437,8 +5437,7 @@ object_getstate_default(PyObject *obj, int required)
for (i = 0; i < slotnames_size; i++) {
PyObject *name, *value;
- name = PyList_GET_ITEM(slotnames, i);
- Py_INCREF(name);
+ name = Py_NewRef(PyList_GET_ITEM(slotnames, i));
if (_PyObject_LookupAttr(obj, name, &value) < 0) {
Py_DECREF(name);
goto error;
@@ -5570,10 +5569,8 @@ _PyObject_GetNewArguments(PyObject *obj, PyObject **args, PyObject **kwargs)
Py_DECREF(newargs);
return -1;
}
- *args = PyTuple_GET_ITEM(newargs, 0);
- Py_INCREF(*args);
- *kwargs = PyTuple_GET_ITEM(newargs, 1);
- Py_INCREF(*kwargs);
+ *args = Py_NewRef(PyTuple_GET_ITEM(newargs, 0));
+ *kwargs = Py_NewRef(PyTuple_GET_ITEM(newargs, 1));
Py_DECREF(newargs);
/* XXX We should perhaps allow None to be passed here. */
@@ -9601,8 +9598,7 @@ super_init_impl(PyObject *self, PyTypeObject *type, PyObject *obj) {
return -1;
Py_INCREF(obj);
}
- Py_INCREF(type);
- Py_XSETREF(su->type, type);
+ Py_XSETREF(su->type, Py_NewRef(type));
Py_XSETREF(su->obj, obj);
Py_XSETREF(su->obj_type, obj_type);
return 0;