gh-99300: Use Py_NewRef() in Python/ directory (#99302)

Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in C files of the Python/ directory.
This commit is contained in:
Victor Stinner 2022-11-10 09:03:39 +01:00 committed by GitHub
parent f883b7f8ee
commit d8f239d86e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 41 additions and 80 deletions

View file

@ -235,8 +235,7 @@ PyObject *args_tuple(PyObject *object,
args = PyTuple_New(1 + (errors != NULL));
if (args == NULL)
return NULL;
Py_INCREF(object);
PyTuple_SET_ITEM(args,0,object);
PyTuple_SET_ITEM(args, 0, Py_NewRef(object));
if (errors) {
PyObject *v;
@ -263,8 +262,7 @@ PyObject *codec_getitem(const char *encoding, int index)
return NULL;
v = PyTuple_GET_ITEM(codecs, index);
Py_DECREF(codecs);
Py_INCREF(v);
return v;
return Py_NewRef(v);
}
/* Helper functions to create an incremental codec. */