From d8f239d86eb70c31aa4c4ac46a1d0a27bdb14b20 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 10 Nov 2022 09:03:39 +0100 Subject: 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. --- Python/pythonrun.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index a0005b32fc..1c7ac4af63 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -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"); -- cgit v1.2.1