diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-08-23 20:08:07 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-08-23 20:08:07 (GMT) |
commit | 2658260f3b4984b03e60cc5856e1203e0cd1f807 (patch) | |
tree | c5520bed95b05cbc09500c281f0be901db94687b /Python | |
parent | 3c9d2efdd4f78c56073dd729f1de89b4844d5263 (diff) | |
download | cpython-2658260f3b4984b03e60cc5856e1203e0cd1f807.zip cpython-2658260f3b4984b03e60cc5856e1203e0cd1f807.tar.gz cpython-2658260f3b4984b03e60cc5856e1203e0cd1f807.tar.bz2 |
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.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index a1777bd..1ee062f 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); |