Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 71349:8d05f697acd4 3.2
catch nasty exception classes with __new__ that doesn't return a exception (closes #11627)
Patch from Andreas Stührk.
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 15 Jul 2011 14:09:26 -0500 |
| parents | 419871c62bb3 |
| children | bc1fbd6f667a |
line wrap: on
line diff
--- a/Python/ceval.c Thu Jul 14 19:57:35 2011 +0200 +++ b/Python/ceval.c Fri Jul 15 14:09:26 2011 -0500 @@ -3413,6 +3413,13 @@ value = PyObject_CallObject(exc, NULL); if (value == NULL) goto raise_error; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto raise_error; + } } else if (PyExceptionInstance_Check(exc)) { value = exc;
