mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-121272: move async for/with validation from compiler to symtable (#121361)
This commit is contained in:
parent
715ec630dd
commit
67a05de17c
2 changed files with 22 additions and 13 deletions
|
@ -3058,11 +3058,6 @@ static int
|
|||
compiler_async_for(struct compiler *c, stmt_ty s)
|
||||
{
|
||||
location loc = LOC(s);
|
||||
if (IS_TOP_LEVEL_AWAIT(c)){
|
||||
assert(c->u->u_ste->ste_coroutine == 1);
|
||||
} else if (c->u->u_scope_type != COMPILER_SCOPE_ASYNC_FUNCTION) {
|
||||
return compiler_error(c, loc, "'async for' outside async function");
|
||||
}
|
||||
|
||||
NEW_JUMP_TARGET_LABEL(c, start);
|
||||
NEW_JUMP_TARGET_LABEL(c, except);
|
||||
|
@ -5781,9 +5776,6 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
|
|||
|
||||
co = optimize_and_assemble(c, 1);
|
||||
compiler_exit_scope(c);
|
||||
if (is_top_level_await && is_async_generator){
|
||||
assert(c->u->u_ste->ste_coroutine == 1);
|
||||
}
|
||||
if (co == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
@ -5925,11 +5917,6 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
|
|||
withitem_ty item = asdl_seq_GET(s->v.AsyncWith.items, pos);
|
||||
|
||||
assert(s->kind == AsyncWith_kind);
|
||||
if (IS_TOP_LEVEL_AWAIT(c)){
|
||||
assert(c->u->u_ste->ste_coroutine == 1);
|
||||
} else if (c->u->u_scope_type != COMPILER_SCOPE_ASYNC_FUNCTION){
|
||||
return compiler_error(c, loc, "'async with' outside async function");
|
||||
}
|
||||
|
||||
NEW_JUMP_TARGET_LABEL(c, block);
|
||||
NEW_JUMP_TARGET_LABEL(c, final);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue