diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-04-15 19:19:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-15 19:19:24 (GMT) |
commit | ea2ae026078b328ddeab060940568a4d3bf1b417 (patch) | |
tree | fba97e66d949767124286ee10bfd64fc56e60a99 /Python/compile.c | |
parent | 5d421d7342fc0d278c129c05bea7028430e94a4e (diff) | |
download | cpython-ea2ae026078b328ddeab060940568a4d3bf1b417.zip cpython-ea2ae026078b328ddeab060940568a4d3bf1b417.tar.gz cpython-ea2ae026078b328ddeab060940568a4d3bf1b417.tar.bz2 |
gh-91276: Make JUMP_IF_TRUE_OR_POP/JUMP_IF_FALSE_OR_POP relative (GH-32215)
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c index 718b521..3b91566 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -7672,6 +7672,21 @@ normalize_jumps(struct assembler *a) last->i_opcode = is_forward ? POP_JUMP_FORWARD_IF_TRUE : POP_JUMP_BACKWARD_IF_TRUE; break; + case JUMP_IF_TRUE_OR_POP: + case JUMP_IF_FALSE_OR_POP: + if (!is_forward) { + /* As far as we can tell, the compiler never emits + * these jumps with a backwards target. If/when this + * exception is raised, we have found a use case for + * a backwards version of this jump (or to replace + * it with the sequence (COPY 1, POP_JUMP_IF_T/F, POP) + */ + PyErr_Format(PyExc_SystemError, + "unexpected %s jumping backwards", + last->i_opcode == JUMP_IF_TRUE_OR_POP ? + "JUMP_IF_TRUE_OR_POP" : "JUMP_IF_FALSE_OR_POP"); + } + break; } } } |