Merge pull request #7858 from tk0miya/7856_autoclass_crashed_for_non_classobj

Fix #7856: autodoc: AttributeError is raised for non-class object
This commit is contained in:
Takeshi KOMIYA 2020-06-26 20:45:01 +09:00 committed by GitHub
commit da395b4132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -17,6 +17,8 @@ Bugs fixed
----------
* #7844: autodoc: Failed to detect module when relative module name given
* #7856: autodoc: AttributeError is raised when non-class object is given to
the autoclass directive
Testing
--------

View File

@ -826,7 +826,12 @@ class Documenter:
self.add_line('', sourcename)
# format the object's signature, if any
sig = self.format_signature()
try:
sig = self.format_signature()
except Exception as exc:
logger.warning(__('error while formatting signature for %s: %s'),
self.fullname, exc, type='autodoc')
return
# generate the directive header and options, if applicable
self.add_directive_header(sig)