GH-123044: Give the POP_TOP after a case test a location in the body, not the pattern. (GH-130627)

This commit is contained in:
Mark Shannon 2025-03-10 17:31:16 +00:00 committed by GitHub
parent 91d6db7ee0
commit be046ee6e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 52 additions and 6 deletions

View file

@ -291,6 +291,7 @@ write_location_info_entry(struct assembler* a, location loc, int isize)
RETURN_IF_ERROR(_PyBytes_Resize(&a->a_linetable, len*2));
}
if (loc.lineno < 0) {
assert(loc.lineno == NO_LOCATION.lineno);
write_location_info_none(a, isize);
return SUCCESS;
}
@ -341,6 +342,18 @@ assemble_location_info(struct assembler *a, instr_sequence *instrs,
{
a->a_lineno = firstlineno;
location loc = NO_LOCATION;
for (int i = instrs->s_used-1; i >= 0; i--) {
instruction *instr = &instrs->s_instrs[i];
if (same_location(instr->i_loc, NEXT_LOCATION)) {
if (IS_TERMINATOR_OPCODE(instr->i_opcode)) {
instr->i_loc = NO_LOCATION;
}
else {
assert(i < instrs->s_used-1);
instr->i_loc = instr[1].i_loc;
}
}
}
int size = 0;
for (int i = 0; i < instrs->s_used; i++) {
instruction *instr = &instrs->s_instrs[i];