Skip to content

Commit

Permalink
bpo-46286: use the new POP_JUMP_IF_NOT_NONE opcode to simplify except* (
Browse files Browse the repository at this point in the history
GH-30439)

Automerge-Triggered-By: GH:iritkatriel
  • Loading branch information
iritkatriel committed Jan 6, 2022
1 parent 9c5fa9c commit 16dfabf
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Python/compile.c
Expand Up @@ -3515,9 +3515,7 @@ compiler_try_except(struct compiler *c, stmt_ty s)
[orig, res] PREP_RERAISE_STAR
[exc] DUP_TOP
[exc, exc] LOAD_CONST None
[exc, exc, None] COMPARE_IS
[exc, is_none] POP_JUMP_IF_FALSE RER
[exc, exc] POP_JUMP_IF_NOT_NONE RER
[exc] POP_TOP
[] JUMP_FORWARD L0
Expand Down Expand Up @@ -3687,9 +3685,7 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
compiler_use_next_block(c, reraise_star);
ADDOP(c, PREP_RERAISE_STAR);
ADDOP(c, DUP_TOP);
ADDOP_LOAD_CONST(c, Py_None);
ADDOP_COMPARE(c, Is);
ADDOP_JUMP(c, POP_JUMP_IF_FALSE, reraise);
ADDOP_JUMP(c, POP_JUMP_IF_NOT_NONE, reraise);
NEXT_BLOCK(c);

/* Nothing to reraise */
Expand Down

0 comments on commit 16dfabf

Please sign in to comment.