diff Python/pythonrun.c @ 63849:55397533da51 2.7

sys.stderr and sys.excepthook can be None at interpreter shutdown, in which case display the appropriate error message. (part of #5319)
author Antoine Pitrou <solipsis@pitrou.net>
date Sun, 08 Aug 2010 21:37:51 +0000
parents bd5f5df7ed78
children a4a27240fe09
line wrap: on
line diff
--- a/Python/pythonrun.c	Sun Aug 08 20:49:49 2010 +0000
+++ b/Python/pythonrun.c	Sun Aug 08 21:37:51 2010 +0000
@@ -1149,7 +1149,7 @@
         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 @@
     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())