From 740050af0493030b1f6ebf0b9ac39a356e2e74b6 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Tue, 31 Jan 2023 23:42:22 +0900 Subject: =?UTF-8?q?[3.10]=20gh-101400:=20Fix=20incorrect=20lineno=20in=20e?= =?UTF-8?q?xception=20message=20on=20contin=E2=80=A6=20(gh-101448)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Python/compile.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Python/compile.c') 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); -- cgit v1.2.1