[3.10] bpo-44298: Backport #26513 to 3.10 (#26516)

* Backport 937cebc93 to 3.10

* Update importlib
This commit is contained in:
Mark Shannon 2021-06-03 19:57:31 +01:00 committed by GitHub
parent 84d80f5f30
commit cea0585b79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 2914 additions and 2859 deletions

View file

@ -1767,7 +1767,6 @@ static int
compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
int preserve_tos)
{
int loc;
switch (info->fb_type) {
case WHILE_LOOP:
case EXCEPTION_HANDLER:
@ -1820,7 +1819,6 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
case WITH:
case ASYNC_WITH:
loc = c->u->u_lineno;
SET_LOC(c, (stmt_ty)info->fb_datum);
ADDOP(c, POP_BLOCK);
if (preserve_tos) {
@ -1835,7 +1833,10 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
ADDOP(c, YIELD_FROM);
}
ADDOP(c, POP_TOP);
c->u->u_lineno = loc;
/* The exit block should appear to execute after the
* statement causing the unwinding, so make the unwinding
* instruction artificial */
c->u->u_lineno = -1;
return 1;
case HANDLER_CLEANUP:
@ -2986,12 +2987,17 @@ compiler_return(struct compiler *c, stmt_ty s)
if (preserve_tos) {
VISIT(c, expr, s->v.Return.value);
} else {
/* Emit instruction with line number for expression */
/* Emit instruction with line number for return value */
if (s->v.Return.value != NULL) {
SET_LOC(c, s->v.Return.value);
ADDOP(c, NOP);
}
}
if (s->v.Return.value == NULL || s->v.Return.value->lineno != s->lineno) {
SET_LOC(c, s);
ADDOP(c, NOP);
}
if (!compiler_unwind_fblock_stack(c, preserve_tos, NULL))
return 0;
if (s->v.Return.value == NULL) {
@ -3010,6 +3016,8 @@ static int
compiler_break(struct compiler *c)
{
struct fblockinfo *loop = NULL;
/* Emit instruction with line number */
ADDOP(c, NOP);
if (!compiler_unwind_fblock_stack(c, 0, &loop)) {
return 0;
}
@ -3028,6 +3036,8 @@ static int
compiler_continue(struct compiler *c)
{
struct fblockinfo *loop = NULL;
/* Emit instruction with line number */
ADDOP(c, NOP);
if (!compiler_unwind_fblock_stack(c, 0, &loop)) {
return 0;
}

3352
Python/importlib.h generated

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff