Merge pull request #9644 from xmo-odoo/fix-sourcename-broken-getattr

Protect `sphinx.ext.autodoc.get_sourcename` against misbehaving `__getattr__`
This commit is contained in:
Takeshi KOMIYA 2021-09-18 01:18:57 +09:00 committed by GitHub
commit 62fd91b8d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -585,8 +585,8 @@ class Documenter:
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__)