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:
Victor Stinner 2022-11-16 18:34:24 +01:00 committed by GitHub
parent 19c1462e8d
commit 8211cf5d28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 40 additions and 74 deletions

View file

@ -428,8 +428,7 @@ _PyCodec_EncodeInternal(PyObject *object,
"encoder must return a tuple (object, integer)");
goto onError;
}
v = PyTuple_GET_ITEM(result,0);
Py_INCREF(v);
v = Py_NewRef(PyTuple_GET_ITEM(result,0));
/* We don't check or use the second (integer) entry. */
Py_DECREF(args);
@ -473,8 +472,7 @@ _PyCodec_DecodeInternal(PyObject *object,
"decoder must return a tuple (object,integer)");
goto onError;
}
v = PyTuple_GET_ITEM(result,0);
Py_INCREF(v);
v = Py_NewRef(PyTuple_GET_ITEM(result,0));
/* We don't check or use the second (integer) entry. */
Py_DECREF(args);
@ -569,8 +567,7 @@ PyObject *codec_getitem_checked(const char *encoding,
if (codec == NULL)
return NULL;
v = PyTuple_GET_ITEM(codec, index);
Py_INCREF(v);
v = Py_NewRef(PyTuple_GET_ITEM(codec, index));
Py_DECREF(codec);
return v;
}