Skip to content

Commit c0c041a

Browse files
authored
GH-106529: Define POP_JUMP_IF_NONE in terms of POP_JUMP_IF_TRUE (GH-106599)
1 parent 1f2921b commit c0c041a

File tree

4 files changed

+281
-235
lines changed

4 files changed

+281
-235
lines changed

Python/bytecodes.c

+7-9
Original file line numberDiff line numberDiff line change
@@ -2282,22 +2282,20 @@ dummy_func(
22822282
JUMPBY(oparg * Py_IsTrue(cond));
22832283
}
22842284

2285-
inst(POP_JUMP_IF_NOT_NONE, (value -- )) {
2286-
if (!Py_IsNone(value)) {
2287-
DECREF_INPUTS();
2288-
JUMPBY(oparg);
2289-
}
2290-
}
2291-
2292-
inst(POP_JUMP_IF_NONE, (value -- )) {
2285+
op(IS_NONE, (value -- b)) {
22932286
if (Py_IsNone(value)) {
2294-
JUMPBY(oparg);
2287+
b = Py_True;
22952288
}
22962289
else {
2290+
b = Py_False;
22972291
DECREF_INPUTS();
22982292
}
22992293
}
23002294

2295+
macro(POP_JUMP_IF_NONE) = IS_NONE + POP_JUMP_IF_TRUE;
2296+
2297+
macro(POP_JUMP_IF_NOT_NONE) = IS_NONE + POP_JUMP_IF_FALSE;
2298+
23012299
inst(JUMP_BACKWARD_NO_INTERRUPT, (--)) {
23022300
/* This bytecode is used in the `yield from` or `await` loop.
23032301
* If there is an interrupt, we want it handled in the innermost

Python/executor_cases.c.h

+66-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)