Skip to content

Commit 69af4d2

Browse files
committed
Protect get_sourcename against misbehaving __getattr__
1 parent cf38356 commit 69af4d2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sphinx/ext/autodoc/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ def process_doc(self, docstrings: List[List[str]]) -> Iterator[str]:
585585
yield from docstringlines
586586

587587
def get_sourcename(self) -> str:
588-
if (getattr(self.object, '__module__', None) and
589-
getattr(self.object, '__qualname__', None)):
588+
if (inspect.safe_getattr(self.object, '__module__', None) and
589+
inspect.safe_getattr(self.object, '__qualname__', None)):
590590
# Get the correct location of docstring from self.object
591591
# to support inherited methods
592592
fullname = '%s.%s' % (self.object.__module__, self.object.__qualname__)

0 commit comments

Comments
 (0)