Kaydet (Commit) 2658260f authored tarafından Benjamin Peterson's avatar Benjamin Peterson

fix #3653 Python could segfault if invalid values were passed to sys.excepthook

Author: Daniel Diniz
Reviewer: Georg Brandl
üst 3c9d2efd
...@@ -1300,6 +1300,13 @@ print_exception(PyObject *f, PyObject *value) ...@@ -1300,6 +1300,13 @@ print_exception(PyObject *f, PyObject *value)
int err = 0; int err = 0;
PyObject *type, *tb; 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); Py_INCREF(value);
fflush(stdout); fflush(stdout);
type = (PyObject *) Py_TYPE(value); type = (PyObject *) Py_TYPE(value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment