sys.stderr and sys.excepthook can be None at interpreter shutdown,

in which case display the appropriate error message.
(part of #5319)
This commit is contained in:
Antoine Pitrou 2010-08-08 21:37:51 +00:00
parent c3c04f7844
commit a03ff6d3cd
1 changed files with 2 additions and 2 deletions

View File

@ -1149,7 +1149,7 @@ PyErr_PrintEx(int set_sys_last_vars)
PySys_SetObject("last_traceback", tb);
}
hook = PySys_GetObject("excepthook");
if (hook) {
if (hook && hook != Py_None) {
PyObject *args = PyTuple_Pack(3,
exception, v, tb ? tb : Py_None);
PyObject *result = PyEval_CallObject(hook, args);
@ -1199,7 +1199,7 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
int err = 0;
PyObject *f = PySys_GetObject("stderr");
Py_INCREF(value);
if (f == NULL)
if (f == NULL || f == Py_None)
fprintf(stderr, "lost sys.stderr\n");
else {
if (Py_FlushLine())