Merge pull request #9760 from tk0miya/9756_classmethod_not_having_func

Fix #9756: autodoc: Crashed if classmethod does not have __func__ attribute
This commit is contained in:
Takeshi KOMIYA 2021-10-27 02:24:05 +09:00 committed by GitHub
commit a16baf1495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -63,6 +63,7 @@ Bugs fixed
generic class generic class
* #9755: autodoc: memory addresses are shown for aliases * #9755: autodoc: memory addresses are shown for aliases
* #9752: autodoc: Failed to detect type annotation for slots attribute * #9752: autodoc: Failed to detect type annotation for slots attribute
* #9756: autodoc: Crashed if classmethod does not have __func__ attribute
* #9630: autosummary: Failed to build summary table if :confval:`primary_domain` * #9630: autosummary: Failed to build summary table if :confval:`primary_domain`
is not 'py' is not 'py'
* #9670: html: Fix download file with special characters * #9670: html: Fix download file with special characters

View File

@ -865,7 +865,7 @@ def getdoc(obj: Any, attrgetter: Callable = safe_getattr,
if cls and name and isclassmethod(obj, cls, name): if cls and name and isclassmethod(obj, cls, name):
for basecls in getmro(cls): for basecls in getmro(cls):
meth = basecls.__dict__.get(name) meth = basecls.__dict__.get(name)
if meth: if meth and hasattr(meth, '__func__'):
return getdoc(meth.__func__) return getdoc(meth.__func__)
doc = attrgetter(obj, '__doc__', None) doc = attrgetter(obj, '__doc__', None)