summaryrefslogtreecommitdiff
path: root/Python/errors.c
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1997-09-30 15:00:18 +0000
committerBarry Warsaw <barry@python.org>1997-09-30 15:00:18 +0000
commitd2375bd7546ee7bddbef29e5148c79c0f2e14adc (patch)
tree7849fa998e8f8ac37399566a2c4d246d5e9566c2 /Python/errors.c
parent1154928b7816b7ee4bdf674690825d0282aaf1e4 (diff)
downloadcpython-d2375bd7546ee7bddbef29e5148c79c0f2e14adc.tar.gz
PyErr_NormalizeException(): If the exception's type is a class and the
instance's class is a subclass of this, then use the instance's class as the exception type.
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 31d9cdff8b..7b8c03f21e 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -206,6 +206,14 @@ PyErr_NormalizeException(exc, val, tb)
Py_DECREF(value);
value = res;
}
+ /* if the class of the instance doesn't exactly match the
+ class of the type, believe the instance
+ */
+ else if (inclass != type) {
+ Py_DECREF(type);
+ type = inclass;
+ Py_INCREF(type);
+ }
}
*exc = type;
*val = value;