Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8616: autodoc: AttributeError when non-class is passed to autoclass #8622

Merged
merged 2 commits into from Dec 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -19,6 +19,8 @@ Bugs fixed
* #8164: autodoc: Classes that inherit mocked class are not documented
* #8602: autodoc: The ``autodoc-process-docstring`` event is emitted to the
non-datadescriptors unexpectedly
* #8616: autodoc: AttributeError is raised on non-class object is passed to
autoclass directive

Testing
--------
Expand Down
6 changes: 5 additions & 1 deletion sphinx/ext/autodoc/__init__.py
Expand Up @@ -1662,7 +1662,11 @@ def get_doc(self, encoding: str = None, ignore: int = None) -> List[List[str]]:
def add_content(self, more_content: Optional[StringList], no_docstring: bool = False
) -> None:
if self.doc_as_attr:
more_content = StringList([_('alias of %s') % restify(self.object)], source='')
try:
more_content = StringList([_('alias of %s') % restify(self.object)], source='')
except AttributeError:
pass # Invalid class object is passed.

super().add_content(more_content, no_docstring=True)
else:
super().add_content(more_content)
Expand Down