Merge pull request #10149 from tk0miya/9876_catch_PycodeError

Fix #9876: autodoc: Failed to document a class on binary module
This commit is contained in:
Takeshi KOMIYA
2022-02-06 15:30:06 +09:00
committed by GitHub
2 changed files with 9 additions and 3 deletions

View File

@@ -16,6 +16,9 @@ Features added
Bugs fixed
----------
* #9876: autodoc: Failed to document an imported class that is built from native
binary module
Testing
--------

View File

@@ -1771,9 +1771,12 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
def add_content(self, more_content: Optional[StringList], no_docstring: bool = False
) -> None:
if self.doc_as_attr and self.modname != self.get_real_modname():
# override analyzer to obtain doccomment around its definition.
self.analyzer = ModuleAnalyzer.for_module(self.modname)
self.analyzer.analyze()
try:
# override analyzer to obtain doccomment around its definition.
self.analyzer = ModuleAnalyzer.for_module(self.modname)
self.analyzer.analyze()
except PycodeError:
pass
if self.doc_as_attr and not self.get_variable_comment():
try: