Skip to content

Commit a03ff6d

Browse files
committed
sys.stderr and sys.excepthook can be None at interpreter shutdown,
in which case display the appropriate error message. (part of #5319)
1 parent c3c04f7 commit a03ff6d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/pythonrun.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ PyErr_PrintEx(int set_sys_last_vars)
11491149
PySys_SetObject("last_traceback", tb);
11501150
}
11511151
hook = PySys_GetObject("excepthook");
1152-
if (hook) {
1152+
if (hook && hook != Py_None) {
11531153
PyObject *args = PyTuple_Pack(3,
11541154
exception, v, tb ? tb : Py_None);
11551155
PyObject *result = PyEval_CallObject(hook, args);
@@ -1199,7 +1199,7 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
11991199
int err = 0;
12001200
PyObject *f = PySys_GetObject("stderr");
12011201
Py_INCREF(value);
1202-
if (f == NULL)
1202+
if (f == NULL || f == Py_None)
12031203
fprintf(stderr, "lost sys.stderr\n");
12041204
else {
12051205
if (Py_FlushLine())

0 commit comments

Comments
 (0)