diff options
author | Barry Warsaw <barry@python.org> | 1997-09-30 15:00:18 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1997-09-30 15:00:18 (GMT) |
commit | 3a749931181b747220904e11535c0fe91594c228 (patch) | |
tree | d546323fa03e7548a71220672f0bfaa73167aa8e /Python | |
parent | 22ecb7107831919bdaf3335feca8f410e3456b10 (diff) | |
download | cpython-3a749931181b747220904e11535c0fe91594c228.zip cpython-3a749931181b747220904e11535c0fe91594c228.tar.gz cpython-3a749931181b747220904e11535c0fe91594c228.tar.bz2 |
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')
-rw-r--r-- | Python/errors.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c index 31d9cdf..7b8c03f 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; |