summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorMehdi ABAAKOUK <sileht@sileht.net>2022-06-30 17:08:38 (GMT)
committerGitHub <noreply@github.com>2022-06-30 17:08:38 (GMT)
commit4261b6bffc0b8bb5c6d4d80578a81b7520f4aefc (patch)
tree004df1f1a95ed6113b55ab0f92d3e66b405fd424 /Lib/inspect.py
parent639e35108bc8b2b880225862d3571277ad57648b (diff)
downloadcpython-4261b6bffc0b8bb5c6d4d80578a81b7520f4aefc.zip
cpython-4261b6bffc0b8bb5c6d4d80578a81b7520f4aefc.tar.gz
cpython-4261b6bffc0b8bb5c6d4d80578a81b7520f4aefc.tar.bz2
gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock (#94050)
The inspect version was not working with unittest.mock.AsyncMock. The fix introduces special-casing of AsyncMock in `inspect.iscoroutinefunction` equivalent to the one performed in `asyncio.iscoroutinefunction`. Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 6e74471..cbc0632 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -395,7 +395,7 @@ def _has_code_flag(f, flag):
while ismethod(f):
f = f.__func__
f = functools._unwrap_partial(f)
- if not isfunction(f):
+ if not (isfunction(f) or _signature_is_functionlike(f)):
return False
return bool(f.__code__.co_flags & flag)