Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adjusted implementation.
  • Loading branch information
carltongibson committed Dec 8, 2022
commit 3bc72e2422ba4f44725525c5eb87989c677c6b34
13 changes: 7 additions & 6 deletions Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,13 @@ def iscoroutinefunction(obj):
Coroutine functions are normally defined with "async def" syntax, but may
be marked via markcoroutinefunction.
"""
func = getattr(obj, "__func__", obj)
if getattr(func, "_is_coroutine", None) is _is_coroutine:
return True

if not isclass(obj) and callable(obj) and getattr(obj.__call__, "_is_coroutine", None) is _is_coroutine:
return True
if not isclass(obj) and callable(obj):
# Test both the function and the __call__ implementation for the
# _is_coroutine marker.
f = getattr(getattr(obj, "__func__", obj), "_is_coroutine", None)
c = getattr(obj.__call__, "_is_coroutine", None)
if f is _is_coroutine or c is _is_coroutine:
return True

return _has_code_flag(obj, CO_COROUTINE) or (
not isclass(obj) and callable(obj) and _has_code_flag(obj.__call__, CO_COROUTINE)
Expand Down