Skip to content

Commit 83c4717

Browse files
committed
gh-101400: Restore continue/break loc for the non-loop case
1 parent f5a3d91 commit 83c4717

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restore continue/break loc for the non-loop case. Patch by Dong-hee Na.

Python/compile.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,11 +3246,12 @@ static int
32463246
compiler_break(struct compiler *c, location loc)
32473247
{
32483248
struct fblockinfo *loop = NULL;
3249+
location origin_loc = loc;
32493250
/* Emit instruction with line number */
32503251
ADDOP(c, loc, NOP);
32513252
RETURN_IF_ERROR(compiler_unwind_fblock_stack(c, &loc, 0, &loop));
32523253
if (loop == NULL) {
3253-
return compiler_error(c, loc, "'break' outside loop");
3254+
return compiler_error(c, origin_loc, "'break' outside loop");
32543255
}
32553256
RETURN_IF_ERROR(compiler_unwind_fblock(c, &loc, loop, 0));
32563257
ADDOP_JUMP(c, loc, JUMP, loop->fb_exit);
@@ -3261,11 +3262,12 @@ static int
32613262
compiler_continue(struct compiler *c, location loc)
32623263
{
32633264
struct fblockinfo *loop = NULL;
3265+
location origin_loc = loc;
32643266
/* Emit instruction with line number */
32653267
ADDOP(c, loc, NOP);
32663268
RETURN_IF_ERROR(compiler_unwind_fblock_stack(c, &loc, 0, &loop));
32673269
if (loop == NULL) {
3268-
return compiler_error(c, loc, "'continue' not properly in loop");
3270+
return compiler_error(c, origin_loc, "'continue' not properly in loop");
32693271
}
32703272
ADDOP_JUMP(c, loc, JUMP, loop->fb_block);
32713273
return SUCCESS;

0 commit comments

Comments
 (0)