summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-07-15 19:09:26 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-07-15 19:09:26 (GMT)
commit5afa03a72ee6d27e742dc0ebc06a0630e1b37fe9 (patch)
tree681215dcb1cb49babcf4677d582591bb37b22c7c /Python
parent1f0ccfa853dcc68d3c2d5b92d22fa0c8e1321b63 (diff)
downloadcpython-5afa03a72ee6d27e742dc0ebc06a0630e1b37fe9.zip
cpython-5afa03a72ee6d27e742dc0ebc06a0630e1b37fe9.tar.gz
cpython-5afa03a72ee6d27e742dc0ebc06a0630e1b37fe9.tar.bz2
catch nasty exception classes with __new__ that doesn't return a exception (closes #11627)
Patch from Andreas Stührk.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 5c3bb83..f0ea7c9 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3413,6 +3413,13 @@ do_raise(PyObject *exc, PyObject *cause)
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;