Skip to content

Commit

Permalink
bpo-45039: Consistently use ADDOP_LOAD_CONST in compiler rather than …
Browse files Browse the repository at this point in the history
…ADDOP_O(c, LOAD_CONST,...) (GH-28015)
  • Loading branch information
iritkatriel committed Aug 31, 2021
1 parent 54f1005 commit 70ccee4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Python/compile.c
Expand Up @@ -1638,12 +1638,14 @@ compiler_addop_j_noline(struct compiler *c, int opcode, basicblock *b)
}

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

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

static int
compiler_call_exit_with_nones(struct compiler *c) {
ADDOP_O(c, LOAD_CONST, Py_None, consts);
ADDOP_LOAD_CONST(c, Py_None);
ADDOP(c, DUP_TOP);
ADDOP(c, DUP_TOP);
ADDOP_I(c, CALL_FUNCTION, 3);
Expand Down Expand Up @@ -5226,7 +5228,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
if(!compiler_call_exit_with_nones(c))
return 0;
ADDOP(c, GET_AWAITABLE);
ADDOP_O(c, LOAD_CONST, Py_None, consts);
ADDOP_LOAD_CONST(c, Py_None);
ADDOP(c, YIELD_FROM);

ADDOP(c, POP_TOP);
Expand Down

0 comments on commit 70ccee4

Please sign in to comment.