mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.10] gh-101400: Fix incorrect lineno in exception message on contin… (gh-101448)
This commit is contained in:
parent
71db9c9ea5
commit
740050af04
3 changed files with 23 additions and 13 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue