Closed
Description
PyObject_GetAttr()
followed by PyErr_ExceptionMatches(PyExc_AttributeError)
and PyErr_Clear()
can be replaced with _PyObject_LookupAttr()
. It is faster, because it avoids raising the AttributeError exception which later be caught and dropped at first place. And it leads to simpler code. Most of code already uses _PyObject_LookupAttr()
, but some new code was added recently which still use the old idiom.