mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-120200: Fix inspect.iscoroutinefunction(inspect) is True
corner case (#120214)
This commit is contained in:
parent
9d6604222e
commit
10fb1b8f36
2 changed files with 4 additions and 3 deletions
|
@ -403,13 +403,13 @@ def isgeneratorfunction(obj):
|
|||
return _has_code_flag(obj, CO_GENERATOR)
|
||||
|
||||
# A marker for markcoroutinefunction and iscoroutinefunction.
|
||||
_is_coroutine_marker = object()
|
||||
_is_coroutine_mark = object()
|
||||
|
||||
def _has_coroutine_mark(f):
|
||||
while ismethod(f):
|
||||
f = f.__func__
|
||||
f = functools._unwrap_partial(f)
|
||||
return getattr(f, "_is_coroutine_marker", None) is _is_coroutine_marker
|
||||
return getattr(f, "_is_coroutine_marker", None) is _is_coroutine_mark
|
||||
|
||||
def markcoroutinefunction(func):
|
||||
"""
|
||||
|
@ -417,7 +417,7 @@ def markcoroutinefunction(func):
|
|||
"""
|
||||
if hasattr(func, '__func__'):
|
||||
func = func.__func__
|
||||
func._is_coroutine_marker = _is_coroutine_marker
|
||||
func._is_coroutine_marker = _is_coroutine_mark
|
||||
return func
|
||||
|
||||
def iscoroutinefunction(obj):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue