From: Barry Warsaw Date: Tue, 30 Sep 1997 15:00:18 +0000 (+0000) Subject: PyErr_NormalizeException(): If the exception's type is a class and the X-Git-Tag: v1.5a4~114 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a749931181b747220904e11535c0fe91594c228;p=python 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. --- 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;