Skip to content

Commit 479bedd

Browse files
Factor out IS_RETURN_OPCODE().
1 parent 076b060 commit 479bedd

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Include/internal/pycore_opcode_utils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ extern "C" {
5454
(opcode) == RAISE_VARARGS || \
5555
(opcode) == RERAISE)
5656

57+
#define IS_RETURN_OPCODE(opcode) \
58+
(opcode == RETURN_VALUE)
59+
5760

5861
/* Flags used in the oparg for MAKE_FUNCTION */
5962
#define MAKE_FUNCTION_DEFAULTS 0x01

Objects/codeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ _PyCode_ReturnsValue(PyCodeObject *co)
17151715
Py_ssize_t len = Py_SIZE(co);
17161716
for (int i = 0; i < len; i++) {
17171717
_Py_CODEUNIT inst = _Py_GetBaseCodeUnit(co, i);
1718-
if (inst.op.code == RETURN_VALUE) {
1718+
if (IS_RETURN_OPCODE(inst.op.code)) {
17191719
assert(i != 0);
17201720
// Ignore it if it returns None.
17211721
_Py_CODEUNIT prev = _Py_GetBaseCodeUnit(co, i-1);

Python/flowgraph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ dump_instr(cfg_instr *i)
295295
static inline int
296296
basicblock_returns(const basicblock *b) {
297297
cfg_instr *last = basicblock_last_instr(b);
298-
return last && last->i_opcode == RETURN_VALUE;
298+
return last && IS_RETURN_OPCODE(last->i_opcode);
299299
}
300300

301301
static void

0 commit comments

Comments
 (0)