catch nasty exception classes with __new__ that doesn't return a exception (closes #11627)
Patch from Andreas Stührk.
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 @@
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;