must clear an AttributeError if it is set

This commit is contained in:
Benjamin Peterson 2011-05-23 18:17:55 -05:00
parent fd89af59e8
commit 7f5cd45f1d
1 changed files with 6 additions and 2 deletions

View 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);