Skip to content

Commit ebbd0ac

Browse files
bpo-45039: Consistently use ADDOP_LOAD_CONST in compiler rather than ADDOP_O(c, LOAD_CONST,...) (GH-28015)
(cherry picked from commit 70ccee4) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
1 parent 337c8ad commit ebbd0ac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Python/compile.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,12 +1568,14 @@ compiler_addop_j_noline(struct compiler *c, int opcode, basicblock *b)
15681568
}
15691569

15701570
#define ADDOP_O(C, OP, O, TYPE) { \
1571+
assert((OP) != LOAD_CONST); /* use ADDOP_LOAD_CONST */ \
15711572
if (!compiler_addop_o((C), (OP), (C)->u->u_ ## TYPE, (O))) \
15721573
return 0; \
15731574
}
15741575

15751576
/* Same as ADDOP_O, but steals a reference. */
15761577
#define ADDOP_N(C, OP, O, TYPE) { \
1578+
assert((OP) != LOAD_CONST); /* use ADDOP_LOAD_CONST_NEW */ \
15771579
if (!compiler_addop_o((C), (OP), (C)->u->u_ ## TYPE, (O))) { \
15781580
Py_DECREF((O)); \
15791581
return 0; \
@@ -1751,7 +1753,7 @@ compiler_pop_fblock(struct compiler *c, enum fblocktype t, basicblock *b)
17511753

17521754
static int
17531755
compiler_call_exit_with_nones(struct compiler *c) {
1754-
ADDOP_O(c, LOAD_CONST, Py_None, consts);
1756+
ADDOP_LOAD_CONST(c, Py_None);
17551757
ADDOP(c, DUP_TOP);
17561758
ADDOP(c, DUP_TOP);
17571759
ADDOP_I(c, CALL_FUNCTION, 3);
@@ -5062,7 +5064,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
50625064
if(!compiler_call_exit_with_nones(c))
50635065
return 0;
50645066
ADDOP(c, GET_AWAITABLE);
5065-
ADDOP_O(c, LOAD_CONST, Py_None, consts);
5067+
ADDOP_LOAD_CONST(c, Py_None);
50665068
ADDOP(c, YIELD_FROM);
50675069

50685070
ADDOP(c, POP_TOP);

0 commit comments

Comments
 (0)