Skip to content

Commit

Permalink
fix python#3653 Python could segfault if invalid values were passed t…
Browse files Browse the repository at this point in the history
…o sys.excepthook

Author: Daniel Diniz
Reviewer: Georg Brandl
  • Loading branch information
benjaminp committed Aug 23, 2008
1 parent 3c9d2ef commit 2658260
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Python/pythonrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2658260

Please sign in to comment.