Skip to content

Commit 70ccee4

Browse files
authored
bpo-45039: Consistently use ADDOP_LOAD_CONST in compiler rather than ADDOP_O(c, LOAD_CONST,...) (GH-28015)
1 parent 54f1005 commit 70ccee4

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
@@ -1638,12 +1638,14 @@ compiler_addop_j_noline(struct compiler *c, int opcode, basicblock *b)
16381638
}
16391639

16401640
#define ADDOP_O(C, OP, O, TYPE) { \
1641+
assert((OP) != LOAD_CONST); /* use ADDOP_LOAD_CONST */ \
16411642
if (!compiler_addop_o((C), (OP), (C)->u->u_ ## TYPE, (O))) \
16421643
return 0; \
16431644
}
16441645

16451646
/* Same as ADDOP_O, but steals a reference. */
16461647
#define ADDOP_N(C, OP, O, TYPE) { \
1648+
assert((OP) != LOAD_CONST); /* use ADDOP_LOAD_CONST_NEW */ \
16471649
if (!compiler_addop_o((C), (OP), (C)->u->u_ ## TYPE, (O))) { \
16481650
Py_DECREF((O)); \
16491651
return 0; \
@@ -1821,7 +1823,7 @@ compiler_pop_fblock(struct compiler *c, enum fblocktype t, basicblock *b)
18211823

18221824
static int
18231825
compiler_call_exit_with_nones(struct compiler *c) {
1824-
ADDOP_O(c, LOAD_CONST, Py_None, consts);
1826+
ADDOP_LOAD_CONST(c, Py_None);
18251827
ADDOP(c, DUP_TOP);
18261828
ADDOP(c, DUP_TOP);
18271829
ADDOP_I(c, CALL_FUNCTION, 3);
@@ -5226,7 +5228,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
52265228
if(!compiler_call_exit_with_nones(c))
52275229
return 0;
52285230
ADDOP(c, GET_AWAITABLE);
5229-
ADDOP_O(c, LOAD_CONST, Py_None, consts);
5231+
ADDOP_LOAD_CONST(c, Py_None);
52305232
ADDOP(c, YIELD_FROM);
52315233

52325234
ADDOP(c, POP_TOP);

0 commit comments

Comments
 (0)