mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
[3.11] gh-101400: Fix incorrect lineno in exception message on contin… (gh-101447)
This commit is contained in:
parent
43af2dbb54
commit
0c37ea9aba
3 changed files with 35 additions and 13 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue