| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3059,7 +3059,7 @@ compiler_async_for(struct compiler *c, stmt_ty s) | |||
| 3059 | 3059 | { | |
| 3060 | 3060 | location loc = LOC(s); | |
| 3061 | 3061 | if (IS_TOP_LEVEL_AWAIT(c)){ | |
| 3062 | - c->u->u_ste->ste_coroutine = 1; | ||
| 3062 | + assert(c->u->u_ste->ste_coroutine == 1); | ||
| 3063 | 3063 | } else if (c->u->u_scope_type != COMPILER_SCOPE_ASYNC_FUNCTION) { | |
| 3064 | 3064 | return compiler_error(c, loc, "'async for' outside async function"); | |
| 3065 | 3065 | } | |
@@ -5782,7 +5782,7 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type, | |||
| 5782 | 5782 | co = optimize_and_assemble(c, 1); | |
| 5783 | 5783 | compiler_exit_scope(c); | |
| 5784 | 5784 | if (is_top_level_await && is_async_generator){ | |
| 5785 | - c->u->u_ste->ste_coroutine = 1; | ||
| 5785 | + assert(c->u->u_ste->ste_coroutine == 1); | ||
| 5786 | 5786 | } | |
| 5787 | 5787 | if (co == NULL) { | |
| 5788 | 5788 | goto error; | |
@@ -5926,7 +5926,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos) | |||
| 5926 | 5926 | ||
| 5927 | 5927 | assert(s->kind == AsyncWith_kind); | |
| 5928 | 5928 | if (IS_TOP_LEVEL_AWAIT(c)){ | |
| 5929 | - c->u->u_ste->ste_coroutine = 1; | ||
| 5929 | + assert(c->u->u_ste->ste_coroutine == 1); | ||
| 5930 | 5930 | } else if (c->u->u_scope_type != COMPILER_SCOPE_ASYNC_FUNCTION){ | |
| 5931 | 5931 | return compiler_error(c, loc, "'async with' outside async function"); | |
| 5932 | 5932 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1681,6 +1681,16 @@ check_import_from(struct symtable *st, stmt_ty s) | |||
| 1681 | 1681 | return 1; | |
| 1682 | 1682 | } | |
| 1683 | 1683 | ||
| 1684 | + static void | ||
| 1685 | + maybe_set_ste_coroutine_for_module(struct symtable *st, stmt_ty s) | ||
| 1686 | + { | ||
| 1687 | + if ((st->st_future->ff_features & PyCF_ALLOW_TOP_LEVEL_AWAIT) && | ||
| 1688 | + (st->st_cur->ste_type == ModuleBlock)) | ||
| 1689 | + { | ||
| 1690 | + st->st_cur->ste_coroutine = 1; | ||
| 1691 | + } | ||
| 1692 | + } | ||
| 1693 | + | ||
| 1684 | 1694 | static int | |
| 1685 | 1695 | symtable_visit_stmt(struct symtable *st, stmt_ty s) | |
| 1686 | 1696 | { | |
@@ -2074,10 +2084,12 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) | |||
| 2074 | 2084 | break; | |
| 2075 | 2085 | } | |
| 2076 | 2086 | case AsyncWith_kind: | |
| 2087 | + maybe_set_ste_coroutine_for_module(st, s); | ||
| 2077 | 2088 | VISIT_SEQ(st, withitem, s->v.AsyncWith.items); | |
| 2078 | 2089 | VISIT_SEQ(st, stmt, s->v.AsyncWith.body); | |
| 2079 | 2090 | break; | |
| 2080 | 2091 | case AsyncFor_kind: | |
| 2092 | + maybe_set_ste_coroutine_for_module(st, s); | ||
| 2081 | 2093 | VISIT(st, expr, s->v.AsyncFor.target); | |
| 2082 | 2094 | VISIT(st, expr, s->v.AsyncFor.iter); | |
| 2083 | 2095 | VISIT_SEQ(st, stmt, s->v.AsyncFor.body); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments