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
Renamed to _is_coroutine_marker.
  • Loading branch information
carltongibson committed Dec 13, 2022
commit c073cf79867a702dc4de6a0659dd9d16bfe4b44e
12 changes: 6 additions & 6 deletions Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,15 @@ def isgeneratorfunction(obj):
return _has_code_flag(obj, CO_GENERATOR)

# A marker for markcoroutinefunction and iscoroutinefunction.
_is_coroutine = object()
_is_coroutine_marker = object()

def markcoroutinefunction(func):
"""
Decorator to ensure callable is recognised as a coroutine function.
"""
if hasattr(func, '__func__'):
func = func.__func__
func._is_coroutine = _is_coroutine
func._is_coroutine_marker = _is_coroutine_marker
return func

def iscoroutinefunction(obj):
Expand All @@ -412,10 +412,10 @@ def iscoroutinefunction(obj):
"""
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:
# _is_coroutine_marker.
f = getattr(getattr(obj, "__func__", obj), "_is_coroutine_marker", None)
c = getattr(obj.__call__, "_is_coroutine_marker", None)
if f is _is_coroutine_marker or c is _is_coroutine_marker:
return True

return _has_code_flag(obj, CO_COROUTINE) or (
Comment thread
gvanrossum marked this conversation as resolved.
Outdated
Expand Down