]> granicus.if.org Git - python/commitdiff
sys.stderr and sys.excepthook can be None at interpreter shutdown,
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 8 Aug 2010 21:37:51 +0000 (21:37 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 8 Aug 2010 21:37:51 +0000 (21:37 +0000)
in which case display the appropriate error message.
(part of #5319)

Python/pythonrun.c

index db5d0a7a189d52ec4717e74d9557b531b45c7c92..7f63ae108cdf55b136696f34cb45ba48e998415e 100644 (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())