Unlike PyObject_GetAttr, this avoids setting the attribute error only to clear it - under some conditions.