[3.10] gh-101400: Fix incorrect lineno in exception message on contin… (gh-101448)

This commit is contained in:
Dong-hee Na 2023-01-31 23:42:22 +09:00 committed by GitHub
parent 71db9c9ea5
commit 740050af04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 13 deletions

View file

@ -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);