8000 gh-94912: Added marker for non-standard coroutine function detection by carltongibson · Pull Request #99247 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-94912: Added marker for non-standard coroutine function detection #99247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Dec 18, 2022
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
Adjust iscoroutinefunction() to look for async __call__.
  • Loading branch information
carltongibson committed Nov 17, 2022
commit fa22a1631ebaf49f54d45eb36057ac3a49ca26f6
4 changes: 3 additions & 1 deletion Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ def iscoroutinefunction(obj):

Coroutine functions are defined with "async def" syntax.
"""
return _has_code_flag(obj, CO_COROUTINE)
return _has_code_flag(obj, CO_COROUTINE) or (
callable(obj) and _has_code_flag(obj.__call__, CO_COROUTINE)
)

def isasyncgenfunction(obj):
"""Return true if the object is an asynchronous generator function.
Expand Down
0