diff options
author | Dong-hee Na <donghee.na@python.org> | 2023-01-31 23:53:14 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-31 23:53:14 +0900 |
commit | 0c37ea9abad2eae146ce117eca0503aaedc96c0f (patch) | |
tree | 47a479282bfea5638bc41469af09339fead985fe /Python | |
parent | 43af2dbb54785e34f67813eee08156647f340b64 (diff) | |
download | cpython3-0c37ea9abad2eae146ce117eca0503aaedc96c0f.tar.gz |
[3.11] gh-101400: Fix incorrect lineno in exception message on contin… (gh-101447)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c index f4555b35ab..17d1df2c51 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3259,12 +3259,20 @@ static int compiler_break(struct compiler *c) { struct fblockinfo *loop = NULL; + int u_lineno = c->u->u_lineno; + int u_col_offset = c->u->u_col_offset; + int u_end_lineno = c->u->u_end_lineno; + int u_end_col_offset = c->u->u_end_col_offset; /* 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 = u_lineno; + c->u->u_col_offset = u_col_offset; + c->u->u_end_lineno = u_end_lineno; + c->u->u_end_col_offset = u_end_col_offset; return compiler_error(c, "'break' outside loop"); } if (!compiler_unwind_fblock(c, loop, 0)) { @@ -3278,12 +3286,20 @@ static int compiler_continue(struct compiler *c) { struct fblockinfo *loop = NULL; + int u_lineno = c->u->u_lineno; + int u_col_offset = c->u->u_col_offset; + int u_end_lineno = c->u->u_end_lineno; + int u_end_col_offset = c->u->u_end_col_offset; /* 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 = u_lineno; + c->u->u_col_offset = u_col_offset; + c->u->u_end_lineno = u_end_lineno; + c->u->u_end_col_offset = u_end_col_offset; return compiler_error(c, "'continue' not properly in loop"); } ADDOP_JUMP(c, JUMP, loop->fb_block); |