summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-11-20 16:33:30 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-11-20 16:33:30 (GMT)
commit6bb9989ae38cd2610e661d6e8899ef58dd9562e3 (patch)
tree3f91b1c8de11bbd1a218d39caf36c0997f5b9cf5 /Objects
parentf149e45a4e3311c2eb6ce63aa0b00b6dcacf01f5 (diff)
downloadcpython-6bb9989ae38cd2610e661d6e8899ef58dd9562e3.zip
cpython-6bb9989ae38cd2610e661d6e8899ef58dd9562e3.tar.gz
cpython-6bb9989ae38cd2610e661d6e8899ef58dd9562e3.tar.bz2
#1574217: only swallow AttributeErrors in isinstance, not everything.
Patch and tests by Brian Harring, with improvements by Ralf Schmitt.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c15
1 files changed, 12 insertions, 3 deletions
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 @@ recursive_isinstance(PyObject *inst, PyObject *cls)
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 @@ recursive_isinstance(PyObject *inst, PyObject *cls)
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);