Skip to content

Commit 62fd91b

Browse files
authored
Merge pull request sphinx-doc#9644 from xmo-odoo/fix-sourcename-broken-getattr
Protect `sphinx.ext.autodoc.get_sourcename` against misbehaving `__getattr__`
2 parents 506590d + 69af4d2 commit 62fd91b

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)