Skip to content

Commit eaefbef

Browse files
committed
Fix #9876: autodoc: ocument a class on binary module
1 parent 99947d9 commit eaefbef

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Features added
1616
Bugs fixed
1717
----------
1818

19+
* #9876: autodoc: Failed to document an imported class that is built from native
20+
binary module
21+
1922
Testing
2023
--------
2124

sphinx/ext/autodoc/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,9 +1771,12 @@ def get_variable_comment(self) -> Optional[List[str]]:
17711771
def add_content(self, more_content: Optional[StringList], no_docstring: bool = False
17721772
) -> None:
17731773
if self.doc_as_attr and self.modname != self.get_real_modname():
1774-
# override analyzer to obtain doccomment around its definition.
1775-
self.analyzer = ModuleAnalyzer.for_module(self.modname)
1776-
self.analyzer.analyze()
1774+
try:
1775+
# override analyzer to obtain doccomment around its definition.
1776+
self.analyzer = ModuleAnalyzer.for_module(self.modname)
1777+
self.analyzer.analyze()
1778+
except PycodeError:
1779+
pass
17771780

17781781
if self.doc_as_attr and not self.get_variable_comment():
17791782
try:

0 commit comments

Comments
 (0)