diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-06-30 11:02:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-30 20:02:15 +0200 |
commit | 47f23b2d8a14a2f182375c840776eadfc371c726 (patch) | |
tree | 76ead06fbb8909c527a9438d7069c795b71ce87f /Lib/inspect.py | |
parent | d915ed297804041c822a595c0f44e52a4c385302 (diff) | |
download | cpython-git-47f23b2d8a14a2f182375c840776eadfc371c726.tar.gz |
gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock (GH-94050) (GH-94461)
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>
(cherry picked from commit 4261b6bffc0b8bb5c6d4d80578a81b7520f4aefc)
Co-authored-by: Mehdi ABAAKOUK <sileht@sileht.net>
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index c5881cc808..01df575e4b 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -294,7 +294,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) |