]> granicus.if.org Git - python/commitdiff
must clear an AttributeError if it is set
authorBenjamin Peterson <benjamin@python.org>
Mon, 23 May 2011 23:17:55 +0000 (18:17 -0500)
committerBenjamin Peterson <benjamin@python.org>
Mon, 23 May 2011 23:17:55 +0000 (18:17 -0500)
Objects/object.c

index 5cf15b6a40f0effa8238e13297e79875ae147aba..94a18d37dbed4c277f16028809ff01029ad8ecf2 100644 (file)
@@ -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);