#1574217: only swallow AttributeErrors in isinstance, not everything.

Patch and tests by Brian Harring, with improvements by Ralf Schmitt.
diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py
index 9482e75..50920c5 100644
--- a/Lib/test/test_isinstance.py
+++ b/Lib/test/test_isinstance.py
@@ -81,6 +81,20 @@
 
         self.assertRaises(TypeError, isinstance, I(), C())
 
+    # check that we don't mask non AttributeErrors
+    # see: http://bugs.python.org/issue1574217
+    def test_isinstance_dont_mask_non_attribute_error(self):
+        class C(object):
+            def getclass(self):
+                raise RuntimeError()
+            __class__=property(getclass)
+
+        c=C()
+        self.assertRaises(RuntimeError, isinstance, c, bool)
+
+        # test another code path
+        class D: pass
+        self.assertRaises(RuntimeError, isinstance, c, D)
 
 
 # These tests are similar to above, but tickle certain code paths in
diff --git a/Misc/ACKS b/Misc/ACKS
index 3cb3a29..9c003e9 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -337,6 +337,7 @@
 Lynda Hardman
 Derek Harland
 Jason Harper
+Brian Harring
 Larry Hastings
 Shane Hathaway
 Rycharde Hawkes
diff --git a/Misc/NEWS b/Misc/NEWS
index cb0e19d..76bf481 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #1574217: isinstance now catches only AttributeError, rather than
+  masking all errors.
+
 - Issue #10391: Don't dereference invalid memory in error messages in the ast
   module.
 
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 4eb33d3..d039a9c 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2500,7 +2500,12 @@
         if (retval == 0) {
             PyObject *c = PyObject_GetAttr(inst, __class__);
             if (c == NULL) {
-                PyErr_Clear();
+                if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+                    PyErr_Clear();
+                }
+                else {
+                    retval = -1;
+                }
             }
             else {
                 if (c != (PyObject *)(inst->ob_type) &&
@@ -2518,8 +2523,12 @@
             return -1;
         icls = PyObject_GetAttr(inst, __class__);
         if (icls == NULL) {
-            PyErr_Clear();
-            retval = 0;
+            if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+                PyErr_Clear();
+            }
+            else {
+                retval = -1;
+            }
         }
         else {
             retval = abstract_issubclass(icls, cls);