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.
Linked PRs
PyObject_GetAttr()followed byPyErr_ExceptionMatches(PyExc_AttributeError)andPyErr_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.Linked PRs