summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 1ee062fe6f..39c86e749f 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1242,7 +1242,10 @@ PyErr_PrintEx(int set_sys_last_vars)
if (exception == NULL)
return;
PyErr_NormalizeException(&exception, &v, &tb);
- tb = tb ? tb : Py_None;
+ if (tb == NULL) {
+ tb = Py_None;
+ Py_INCREF(tb);
+ }
PyException_SetTraceback(v, tb);
if (exception == NULL)
return;