Skip to content

Commit

Permalink
Merge pull request sphinx-doc#9644 from xmo-odoo/fix-sourcename-broke…
Browse files Browse the repository at this point in the history
…n-getattr

Protect `sphinx.ext.autodoc.get_sourcename` against misbehaving `__getattr__`
  • Loading branch information
tk0miya committed Sep 17, 2021
2 parents 506590d + 69af4d2 commit 62fd91b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sphinx/ext/autodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@ def process_doc(self, docstrings: List[List[str]]) -> Iterator[str]:
yield from docstringlines

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

0 comments on commit 62fd91b

Please sign in to comment.