Skip to content

Commit ffda012

Browse files
author
benjamin.peterson
committed
fix #3653 Python could segfault if invalid values were passed to sys.excepthook
Author: Daniel Diniz Reviewer: Georg Brandl git-svn-id: http://svn.python.org/projects/python/branches/py3k@65998 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 48a14b0 commit ffda012

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Python/pythonrun.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,13 @@ print_exception(PyObject *f, PyObject *value)
13001300
int err = 0;
13011301
PyObject *type, *tb;
13021302

1303+
if (!PyExceptionInstance_Check(value)) {
1304+
PyFile_WriteString("TypeError: print_exception(): Exception expected for value, ", f);
1305+
PyFile_WriteString(Py_TYPE(value)->tp_name, f);
1306+
PyFile_WriteString(" found\n", f);
1307+
return;
1308+
}
1309+
13031310
Py_INCREF(value);
13041311
fflush(stdout);
13051312
type = (PyObject *) Py_TYPE(value);

0 commit comments

Comments
 (0)