Skip to content

Commit

Permalink
pythongh-101400: Restore continue/break loc for the non-loop case
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Jan 30, 2023
1 parent 666c084 commit 099b2a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Restore continue/break loc for the non-loop case. Patch by Dong-hee Na.
6 changes: 4 additions & 2 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3246,11 +3246,12 @@ static int
compiler_break(struct compiler *c, location loc)
{
struct fblockinfo *loop = NULL;
location origin_loc = loc;
/* Emit instruction with line number */
ADDOP(c, loc, NOP);
RETURN_IF_ERROR(compiler_unwind_fblock_stack(c, &loc, 0, &loop));
if (loop == NULL) {
return compiler_error(c, loc, "'break' outside loop");
return compiler_error(c, origin_loc, "'break' outside loop");
}
RETURN_IF_ERROR(compiler_unwind_fblock(c, &loc, loop, 0));
ADDOP_JUMP(c, loc, JUMP, loop->fb_exit);
Expand All @@ -3261,11 +3262,12 @@ static int
compiler_continue(struct compiler *c, location loc)
{
struct fblockinfo *loop = NULL;
location origin_loc = loc;
/* Emit instruction with line number */
ADDOP(c, loc, NOP);
RETURN_IF_ERROR(compiler_unwind_fblock_stack(c, &loc, 0, &loop));
if (loop == NULL) {
return compiler_error(c, loc, "'continue' not properly in loop");
return compiler_error(c, origin_loc, "'continue' not properly in loop");
}
ADDOP_JUMP(c, loc, JUMP, loop->fb_block);
return SUCCESS;
Expand Down

0 comments on commit 099b2a6

Please sign in to comment.