Skip to content

Commit

Permalink
Merge pull request #6657 from tk0miya/6605_crash_with_methodlikeobj
Browse files Browse the repository at this point in the history
Fix #6605: autodoc: crashed when target code contains custom method-like objects
  • Loading branch information
tk0miya authored Aug 18, 2019
2 parents 4a1df77 + 65e2fdc commit 4ab751c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Bugs fixed
imports when ``'bysource'`` order
* #6574: autodoc: missing type annotation for variadic and keyword parameters
* #6589: autodoc: Formatting issues with autodoc_typehints='none'
* #6605: autodoc: crashed when target code contains custom method-like objects
* #6498: autosummary: crashed with wrong autosummary_generate setting
* #6507: autosummary: crashes without no autosummary_generate setting
* #6511: LaTeX: autonumbered list can not be customized in LaTeX
Expand Down
7 changes: 5 additions & 2 deletions sphinx/util/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,12 @@ def isbuiltin(obj: Any) -> bool:

def iscoroutinefunction(obj: Any) -> bool:
"""Check if the object is coroutine-function."""
if inspect.iscoroutinefunction(obj):
if hasattr(obj, '__code__') and inspect.iscoroutinefunction(obj):
# check obj.__code__ because iscoroutinefunction() crashes for custom method-like
# objects (see https://github.com/sphinx-doc/sphinx/issues/6605)
return True
elif ispartial(obj) and inspect.iscoroutinefunction(obj.func):
elif (ispartial(obj) and hasattr(obj.func, '__code__') and
inspect.iscoroutinefunction(obj.func)):
# partialed
return True
else:
Expand Down

0 comments on commit 4ab751c

Please sign in to comment.