From: Benjamin Peterson Date: Mon, 23 May 2011 23:17:55 +0000 (-0500) Subject: must clear an AttributeError if it is set X-Git-Tag: v2.7.2rc1~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f5cd45f1d756e9d749c87ebd62cdb7ad7299366;p=python must clear an AttributeError if it is set --- 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);