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 31d9cdf..7b8c03f 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -206,6 +206,14 @@
 			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;