]> granicus.if.org Git - python/commitdiff
PyErr_NormalizeException(): If the exception's type is a class and the
authorBarry Warsaw <barry@python.org>
Tue, 30 Sep 1997 15:00:18 +0000 (15:00 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 30 Sep 1997 15:00:18 +0000 (15:00 +0000)
instance's class is a subclass of this, then use the instance's class
as the exception type.

Python/errors.c

index 31d9cdff8b2f3a7c7ab9be4ee7d4610445d15c02..7b8c03f21e0f1aadb5259482f68a72dff21052de 100644 (file)
@@ -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;