summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-07-15 14:15:40 -0500
committerBenjamin Peterson <benjamin@python.org>2011-07-15 14:15:40 -0500
commitc3349cd22e9877a0516d8baa71530f87bf5ac430 (patch)
treede647565e7bf267a9fa1b2371ab8c8f08275e65a /Python
parent2659140a5d0fbace2826320c0c3130e356c3c94b (diff)
downloadcpython-git-c3349cd22e9877a0516d8baa71530f87bf5ac430.tar.gz
port 8d05f697acd4 (#11627)
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 10dd3a1f29..06ada97274 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3515,9 +3515,17 @@ do_raise(PyObject *type, PyObject *value, PyObject *tb)
Py_DECREF(tmp);
}
- if (PyExceptionClass_Check(type))
+ if (PyExceptionClass_Check(type)) {
PyErr_NormalizeException(&type, &value, &tb);
-
+ if (!PyExceptionInstance_Check(value)) {
+ PyErr_Format(PyExc_TypeError,
+ "calling %s() should have returned an instance of "
+ "BaseException, not '%s'",
+ ((PyTypeObject *)type)->tp_name,
+ Py_TYPE(value)->tp_name);
+ goto raise_error;
+ }
+ }
else if (PyExceptionInstance_Check(type)) {
/* Raising an instance. The value should be a dummy. */
if (value != Py_None) {