summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c
index e5438f7d00..80caa8fab1 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3030,12 +3030,14 @@ static int
compiler_break(struct compiler *c)
{
struct fblockinfo *loop = NULL;
+ int origin_loc = c->u->u_lineno;
/* Emit instruction with line number */
ADDOP(c, NOP);
if (!compiler_unwind_fblock_stack(c, 0, &loop)) {
return 0;
}
if (loop == NULL) {
+ c->u->u_lineno = origin_loc;
return compiler_error(c, "'break' outside loop");
}
if (!compiler_unwind_fblock(c, loop, 0)) {
@@ -3050,12 +3052,14 @@ static int
compiler_continue(struct compiler *c)
{
struct fblockinfo *loop = NULL;
+ int origin_loc = c->u->u_lineno;
/* Emit instruction with line number */
ADDOP(c, NOP);
if (!compiler_unwind_fblock_stack(c, 0, &loop)) {
return 0;
}
if (loop == NULL) {
+ c->u->u_lineno = origin_loc;
return compiler_error(c, "'continue' not properly in loop");
}
ADDOP_JUMP(c, JUMP_ABSOLUTE, loop->fb_block);