8000 Only print the traceback if there was an exception. · python/cpython@cdb517d · GitHub
[go: up one dir, main page]

Skip to content

Commit cdb517d

Browse files
Only print the traceback if there was an exception.
1 parent 556bee4 commit cdb517d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Modules/_xxsubinterpretersmodule.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,13 @@ _run_script(PyInterpreterState *interp, const char *codestr,
450450
"RunFailedError: script raised an uncaught exception (%s)",
451451
failure);
452452
}
453-
// XXX Instead, store the rendered traceback on sharedexc,
454-
// attach it to the exception when applied,
455-
// and teach PyErr_Display() to print it.
456-
PyErr_Display(NULL, excval, NULL);
457-
Py_XDECREF(excval);
453+
if (excval != NULL) {
454+
// XXX Instead, store the rendered traceback on sharedexc,
455+
// attach it to the exception when applied,
456+
// and teach PyErr_Display() to print it.
457+
PyErr_Display(NULL, excval, NULL);
458+
Py_DECREF(excval);
459+
}
458460
if (errcode != ERR_ALREADY_RUNNING) {
459461
_PyInterpreterState_SetNotRunningMain(interp);
460462
}

0 commit comments

Comments
 (0)
0