From 9fd40d3ab36c19b1f3cdbf101b0b36b20bd9f95b Mon Sep 17 00:00:00 2001 From: Christian Walch Date: Fri, 1 Apr 2022 06:25:32 +0200 Subject: [PATCH] Use `safe_getattr()` to access `__self__`. --- sphinx/util/inspect.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index e226c74dc..33a491e3e 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -305,10 +305,7 @@ def isabstractmethod(obj: Any) -> bool: def isboundmethod(method: MethodType) -> bool: """Check if the method is a bound method.""" - try: - return method.__self__ is not None - except AttributeError: - return False + return safe_getattr(method, '__self__', None) is not None def is_cython_function_or_method(obj: Any) -> bool: