Skip to content

Commit dbb2fd6

Browse files
committed
raise SystemError if our assumption about these jumps always being forward turns out wrong
1 parent 24a1d39 commit dbb2fd6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Python/compile.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7672,6 +7672,21 @@ normalize_jumps(struct assembler *a)
76727672
last->i_opcode = is_forward ?
76737673
POP_JUMP_FORWARD_IF_TRUE : POP_JUMP_BACKWARD_IF_TRUE;
76747674
break;
7675+
case JUMP_IF_TRUE_OR_POP:
7676+
case JUMP_IF_FALSE_OR_POP:
7677+
if (!is_forward) {
7678+
/* As far as we can tell, the compiler never emits
7679+
* these jumps with a backwards target. If/when this
7680+
* exception is raised, we have found a use case for
7681+
* a backwards version of this jump (or to replace
7682+
* it with the sequence (COPY 1, POP_JUMP_IF_T/F, POP)
7683+
*/
7684+
PyErr_Format(PyExc_SystemError,
7685+
"unexpected %s jumping backwards",
7686+
last->i_opcode == JUMP_IF_TRUE_OR_POP ?
7687+
"JUMP_IF_TRUE_OR_POP" : "JUMP_IF_FALSE_OR_POP");
7688+
}
7689+
break;
76757690
}
76767691
}
76777692
}

0 commit comments

Comments
 (0)