Skip to content

Commit 16dfabf

Browse files
authored
bpo-46286: use the new POP_JUMP_IF_NOT_NONE opcode to simplify except* (GH-30439)
Automerge-Triggered-By: GH:iritkatriel
1 parent 9c5fa9c commit 16dfabf

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Python/compile.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3515,9 +3515,7 @@ compiler_try_except(struct compiler *c, stmt_ty s)
35153515
35163516
[orig, res] PREP_RERAISE_STAR
35173517
[exc] DUP_TOP
3518-
[exc, exc] LOAD_CONST None
3519-
[exc, exc, None] COMPARE_IS
3520-
[exc, is_none] POP_JUMP_IF_FALSE RER
3518+
[exc, exc] POP_JUMP_IF_NOT_NONE RER
35213519
[exc] POP_TOP
35223520
[] JUMP_FORWARD L0
35233521
@@ -3687,9 +3685,7 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
36873685
compiler_use_next_block(c, reraise_star);
36883686
ADDOP(c, PREP_RERAISE_STAR);
36893687
ADDOP(c, DUP_TOP);
3690-
ADDOP_LOAD_CONST(c, Py_None);
3691-
ADDOP_COMPARE(c, Is);
3692-
ADDOP_JUMP(c, POP_JUMP_IF_FALSE, reraise);
3688+
ADDOP_JUMP(c, POP_JUMP_IF_NOT_NONE, reraise);
36933689
NEXT_BLOCK(c);
36943690

36953691
/* Nothing to reraise */

0 commit comments

Comments
 (0)