summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-05-23 18:17:55 -0500
committerBenjamin Peterson <benjamin@python.org>2011-05-23 18:17:55 -0500
commit01e8e6d6e8bd22049c3d850aed0262578c185390 (patch)
treea250ee158943890eb54bd8b9cdd3ff346fb302cd
parent7384c85a664f22d4703aea4ceca6e1dc2a74cafa (diff)
downloadcpython-01e8e6d6e8bd22049c3d850aed0262578c185390.tar.gz
must clear an AttributeError if it is set
-rw-r--r--Objects/object.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 5cf15b6a40..94a18d37db 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1911,8 +1911,12 @@ _dir_object(PyObject *obj)
assert(obj);
if (PyInstance_Check(obj)) {
dirfunc = PyObject_GetAttrString(obj, "__dir__");
- if (dirfunc == NULL && !PyErr_ExceptionMatches(PyExc_AttributeError))
- return NULL;
+ if (dirfunc == NULL) {
+ if (PyErr_ExceptionMatches(PyExc_AttributeError))
+ PyErr_Clear();
+ else
+ return NULL;
+ }
}
else {
dirfunc = _PyObject_LookupSpecial(obj, "__dir__", &dir_str);