[Python-checkins] cpython (2.7): must clear an AttributeError if it is set

benjamin.peterson python-checkins at python.org
Tue May 24 01:17:51 CEST 2011


http://hg.python.org/cpython/rev/d70533533f77
changeset:   70326:d70533533f77
branch:      2.7
parent:      70322:90399e508ce3
user:        Benjamin Peterson <benjamin at python.org>
date:        Mon May 23 18:17:55 2011 -0500
summary:
  must clear an AttributeError if it is set

files:
  Objects/object.c |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Objects/object.c b/Objects/object.c
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1911,8 +1911,12 @@
     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);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list