Skip to content

bpo-43495 : Push missing frame block in compile.c #24865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ compiler IR.
*/

enum fblocktype { WHILE_LOOP, FOR_LOOP, TRY_EXCEPT, FINALLY_TRY, FINALLY_END,
WITH, ASYNC_WITH, HANDLER_CLEANUP, POP_VALUE, EXCEPTION_HANDLER };
WITH, ASYNC_WITH, HANDLER_CLEANUP, POP_VALUE, EXCEPTION_HANDLER,
ASYNC_COMPREHENSION_GENERATOR };

struct fblockinfo {
enum fblocktype fb_type;
Expand Down Expand Up @@ -1713,6 +1714,7 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
switch (info->fb_type) {
case WHILE_LOOP:
case EXCEPTION_HANDLER:
case ASYNC_COMPREHENSION_GENERATOR:
return 1;

case FOR_LOOP:
Expand Down Expand Up @@ -4580,6 +4582,11 @@ compiler_async_comprehension_generator(struct compiler *c,
}

compiler_use_next_block(c, start);
/* Runtime will push a block here, so we need to account for that */
if (!compiler_push_fblock(c, ASYNC_COMPREHENSION_GENERATOR, start,
NULL, NULL)) {
return 0;
}

ADDOP_JUMP(c, SETUP_FINALLY, except);
ADDOP(c, GET_ANEXT);
Expand Down Expand Up @@ -4634,6 +4641,8 @@ compiler_async_comprehension_generator(struct compiler *c,
compiler_use_next_block(c, if_cleanup);
ADDOP_JUMP(c, JUMP_ABSOLUTE, start);

compiler_pop_fblock(c, ASYNC_COMPREHENSION_GENERATOR, start);

compiler_use_next_block(c, except);
ADDOP(c, END_ASYNC_FOR);

Expand Down