summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-08 21:37:51 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-08 21:37:51 (GMT)
commita03ff6d3cde5184746bbf9d6f5355402628cbbd7 (patch)
tree08b83a7a249e7aa719a67b48adf01e5d3a63df30 /Python/pythonrun.c
parentc3c04f7844315fff4daa41b53ba24f4ac5d8560e (diff)
downloadcpython-a03ff6d3cde5184746bbf9d6f5355402628cbbd7.zip
cpython-a03ff6d3cde5184746bbf9d6f5355402628cbbd7.tar.gz
cpython-a03ff6d3cde5184746bbf9d6f5355402628cbbd7.tar.bz2
sys.stderr and sys.excepthook can be None at interpreter shutdown,
in which case display the appropriate error message. (part of #5319)
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index db5d0a7..7f63ae1 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -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())