summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-10 09:03:39 +0100
committerGitHub <noreply@github.com>2022-11-10 09:03:39 +0100
commitd8f239d86eb70c31aa4c4ac46a1d0a27bdb14b20 (patch)
tree7055b2d966bf41e636751177cea0248b56072e92 /Python/pythonrun.c
parentf883b7f8ee3209b52863fc662343c8cd81abdc59 (diff)
downloadcpython-git-d8f239d86eb70c31aa4c4ac46a1d0a27bdb14b20.tar.gz
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.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c9
1 files changed, 3 insertions, 6 deletions
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");