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

@ -798,8 +798,7 @@ pycore_init_builtins(PyThreadState *tstate)
if (builtins_dict == NULL) {
goto error;
}
Py_INCREF(builtins_dict);
interp->builtins = builtins_dict;
interp->builtins = Py_NewRef(builtins_dict);
PyObject *isinstance = PyDict_GetItem(builtins_dict, &_Py_ID(isinstance));
assert(isinstance);
@ -2289,8 +2288,7 @@ create_stdio(const PyConfig *config, PyObject* io,
goto error;
}
else {
raw = buf;
Py_INCREF(raw);
raw = Py_NewRef(buf);
}
#ifdef MS_WINDOWS
@ -2552,8 +2550,7 @@ _Py_FatalError_PrintExc(PyThreadState *tstate)
_PyErr_NormalizeException(tstate, &exception, &v, &tb);
if (tb == NULL) {
tb = Py_None;
Py_INCREF(tb);
tb = Py_NewRef(Py_None);
}
PyException_SetTraceback(v, tb);
if (exception == NULL) {