mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
This commit is contained in:
parent
19c1462e8d
commit
8211cf5d28
18 changed files with 40 additions and 74 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue