Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 71354:45b1ae1ef318 2.7
port 8d05f697acd4 (#11627)
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 15 Jul 2011 14:15:40 -0500 |
| parents | cd8d3c2d3bce |
| children |
line wrap: on
line diff
--- a/Python/ceval.c Thu Jul 14 19:49:02 2011 +0200 +++ b/Python/ceval.c Fri Jul 15 14:15:40 2011 -0500 @@ -3515,9 +3515,17 @@ 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) {
