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

@ -786,8 +786,7 @@ _PyErr_PrintEx(PyThreadState *tstate, int set_sys_last_vars)
_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) {
@ -833,12 +832,10 @@ _PyErr_PrintEx(PyThreadState *tstate, int set_sys_last_vars)
to be NULL. However PyErr_Display() can't
tolerate NULLs, so just be safe. */
if (exception2 == NULL) {
exception2 = Py_None;
Py_INCREF(exception2);
exception2 = Py_NewRef(Py_None);
}
if (v2 == NULL) {
v2 = Py_None;
Py_INCREF(v2);
v2 = Py_NewRef(Py_None);
}
fflush(stdout);
PySys_WriteStderr("Error in sys.excepthook:\n");