From 9052f7a41b90f2d34011c8da68f9a4facebc8a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Ta=C5=9Fkaya?= <47358913+isidentical@users.noreply.github.com> Date: Thu, 19 Mar 2020 14:35:44 +0300 Subject: bpo-39562: Allow executing asynchronous comprehensions in the asyncio REPL (GH-18968) Co-authored-by: Pablo Galindo --- Python/compile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Python/compile.c') diff --git a/Python/compile.c b/Python/compile.c index a8ab873f31..fa4313a32c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4520,11 +4520,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)) { -- cgit v1.2.1