diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-03-19 11:54:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-19 11:54:16 (GMT) |
commit | ec8a973f7cf080d9c0679f058b2371f0b7c7862c (patch) | |
tree | 0aa575a974ae82609b4f9cae3702d20811c52114 /Python | |
parent | da1fe768e582387212201ab8737a1a5f26110664 (diff) | |
download | cpython-ec8a973f7cf080d9c0679f058b2371f0b7c7862c.zip cpython-ec8a973f7cf080d9c0679f058b2371f0b7c7862c.tar.gz cpython-ec8a973f7cf080d9c0679f058b2371f0b7c7862c.tar.bz2 |
bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL (GH-18968)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
(cherry picked from commit 9052f7a41b90f2d34011c8da68f9a4facebc8a97)
Co-authored-by: Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c index 9cc7654..913ec99 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4469,11 +4469,14 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type, PyCodeObject *co = NULL; comprehension_ty outermost; PyObject *qualname = NULL; - int is_async_function = c->u->u_ste->ste_coroutine; int is_async_generator = 0; - outermost = (comprehension_ty) asdl_seq_GET(generators, 0); + if (IS_TOP_LEVEL_AWAIT(c)) { + c->u->u_ste->ste_coroutine = 1; + } + int is_async_function = c->u->u_ste->ste_coroutine; + outermost = (comprehension_ty) asdl_seq_GET(generators, 0); if (!compiler_enter_scope(c, name, COMPILER_SCOPE_COMPREHENSION, (void *)e, e->lineno)) { |