Use safe_getattr() to access __self__.

This commit is contained in:
Christian Walch 2022-04-01 06:25:32 +02:00
parent 439485e837
commit 9fd40d3ab3

View File

@ -305,10 +305,7 @@ def isabstractmethod(obj: Any) -> bool:
def isboundmethod(method: MethodType) -> bool: def isboundmethod(method: MethodType) -> bool:
"""Check if the method is a bound method.""" """Check if the method is a bound method."""
try: return safe_getattr(method, '__self__', None) is not None
return method.__self__ is not None
except AttributeError:
return False
def is_cython_function_or_method(obj: Any) -> bool: def is_cython_function_or_method(obj: Any) -> bool: