summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-08-23 20:08:07 +0000
committerBenjamin Peterson <benjamin@python.org>2008-08-23 20:08:07 +0000
commit0194a18417c6e57748cdd3f9eae7c2ad384ca84d (patch)
tree18d2c257919516241fdf5c079a5ec6afe1952fe1 /Python
parent86ea88a67371ed8b4668fb6a02f99d7d22b2d855 (diff)
downloadcpython-0194a18417c6e57748cdd3f9eae7c2ad384ca84d.tar.gz
fix #3653 Python could segfault if invalid values were passed to sys.excepthook
Author: Daniel Diniz Reviewer: Georg Brandl
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index a1777bd5b2..1ee062fe6f 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1300,6 +1300,13 @@ print_exception(PyObject *f, PyObject *value)
int err = 0;
PyObject *type, *tb;
+ if (!PyExceptionInstance_Check(value)) {
+ PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f);
+ PyFile_WriteString(Py_TYPE(value)->tp_name, f);
+ PyFile_WriteString(" found\n", f);
+ return;
+ }
+
Py_INCREF(value);
fflush(stdout);
type = (PyObject *) Py_TYPE(value);