Fix #10009: autodoc: Crashes if subject raises an error on getdoc()

This commit is contained in:
Takeshi KOMIYA 2021-12-24 01:48:22 +09:00
parent 6ad6594ec7
commit 6c6fed5e55
2 changed files with 88 additions and 85 deletions

View File

@ -46,6 +46,7 @@ Bugs fixed
with Python 3.10 with Python 3.10
* #9968: autodoc: instance variables are not shown if __init__ method has * #9968: autodoc: instance variables are not shown if __init__ method has
position-only-arguments position-only-arguments
* #10009: autodoc: Crashes if target object raises an error on getting docstring
* #9947: i18n: topic directive having a bullet list can't be translatable * #9947: i18n: topic directive having a bullet list can't be translatable
* #9878: mathjax: MathJax configuration is placed after loading MathJax itself * #9878: mathjax: MathJax configuration is placed after loading MathJax itself
* #9857: Generated RFC links use outdated base url * #9857: Generated RFC links use outdated base url

View File

@ -711,6 +711,7 @@ class Documenter:
# process members and determine which to skip # process members and determine which to skip
for obj in members: for obj in members:
try:
membername, member = obj membername, member = obj
# if isattr is True, the member is documented as an attribute # if isattr is True, the member is documented as an attribute
if member is INSTANCEATTR: if member is INSTANCEATTR:
@ -754,12 +755,14 @@ class Documenter:
if ismock(member) and (namespace, membername) not in attr_docs: if ismock(member) and (namespace, membername) not in attr_docs:
# mocked module or object # mocked module or object
pass pass
elif self.options.exclude_members and membername in self.options.exclude_members: elif (self.options.exclude_members and
membername in self.options.exclude_members):
# remove members given by exclude-members # remove members given by exclude-members
keep = False keep = False
elif want_all and special_member_re.match(membername): elif want_all and special_member_re.match(membername):
# special __methods__ # special __methods__
if self.options.special_members and membername in self.options.special_members: if (self.options.special_members and
membername in self.options.special_members):
if membername == '__doc__': if membername == '__doc__':
keep = False keep = False
elif is_filtered_inherited_member(membername, obj): elif is_filtered_inherited_member(membername, obj):
@ -803,7 +806,6 @@ class Documenter:
# should be skipped # should be skipped
if self.env.app: if self.env.app:
# let extensions preprocess docstrings # let extensions preprocess docstrings
try:
skip_user = self.env.app.emit_firstresult( skip_user = self.env.app.emit_firstresult(
'autodoc-skip-member', self.objtype, membername, member, 'autodoc-skip-member', self.objtype, membername, member,
not keep, self.options) not keep, self.options)