summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-17 00:44:53 +0200
committerVictor Stinner <victor.stinner@gmail.com>2013-07-17 00:44:53 +0200
commit0302b1098edae221ddc2b4a4fe34b05e1a38958c (patch)
tree78ee217493d5529fe211c5a7ae768e24d7c3585c /Python
parent4a24ef255230351821289b34f0bc4fdd546f86ea (diff)
downloadcpython-0302b1098edae221ddc2b4a4fe34b05e1a38958c.tar.gz
Issue #18408: Fix PyErr_NormalizeException(), handle PyObject_IsSubclass() failure
PyObject_IsSubclass() can fail and raise a new exception!
Diffstat (limited to 'Python')
-rw-r--r--Python/errors.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 34445b65ea..53dd9a9650 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -227,12 +227,21 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
value will be an instance.
*/
if (PyExceptionClass_Check(type)) {
+ int is_subclass;
+ if (inclass) {
+ is_subclass = PyObject_IsSubclass(inclass, type);
+ if (is_subclass < 0)
+ goto finally;
+ }
+ else
+ is_subclass = 0;
+
/* if the value was not an instance, or is not an instance
whose class is (or is derived from) type, then use the
value as an argument to instantiation of the type
class.
*/
- if (!inclass || !PyObject_IsSubclass(inclass, type)) {
+ if (!inclass || !is_subclass) {
PyObject *args, *res;
if (value == Py_None)