Skip to content

Commit e21ae1a

Browse files
Add support for PyCF_ALLOW_TOP_LEVEL_AWAIT.
1 parent ccd55a4 commit e21ae1a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Python/compile.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,8 +4589,9 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
45894589
PyObject *qualname = NULL;
45904590
int scope_type = c->u->u_scope_type;
45914591
int is_async_generator = 0;
4592+
int is_top_level_await = IS_TOP_LEVEL_AWAIT(c);
45924593

4593-
if (IS_TOP_LEVEL_AWAIT(c)) {
4594+
if (is_top_level_await) {
45944595
c->u->u_ste->ste_coroutine = 1;
45954596
}
45964597

@@ -4605,7 +4606,8 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
46054606

46064607
if (is_async_generator && type != COMP_GENEXP &&
46074608
scope_type != COMPILER_SCOPE_ASYNC_FUNCTION &&
4608-
scope_type != COMPILER_SCOPE_COMPREHENSION)
4609+
scope_type != COMPILER_SCOPE_COMPREHENSION &&
4610+
!is_top_level_await)
46094611
{
46104612
compiler_error(c, "asynchronous comprehension outside of "
46114613
"an asynchronous function");

0 commit comments

Comments
 (0)