Skip to content

Commit d5132dd

Browse files
committed
pythongh-103082: use IS_VALID_OPCODE instead of _PyOpcode_OpName to check if an opcode is defined
1 parent d93b4ac commit d5132dd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Python/instrumentation.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "pycore_namespace.h"
88
#include "pycore_object.h"
99
#include "pycore_opcode.h"
10+
#include "pycore_opcode_metadata.h" // IS_VALID_OPCODE
1011
#include "pycore_pyerrors.h"
1112
#include "pycore_pystate.h" // _PyInterpreterState_GET()
1213

@@ -437,11 +438,10 @@ dump_instrumentation_data(PyCodeObject *code, int star, FILE*out)
437438
static bool
438439
valid_opcode(int opcode)
439440
{
440-
if (opcode > 0 &&
441+
if (IS_VALID_OPCODE(opcode) &&
442+
opcode != CACHE &&
441443
opcode != RESERVED &&
442-
opcode < 255 &&
443-
_PyOpcode_OpName[opcode] &&
444-
_PyOpcode_OpName[opcode][0] != '<')
444+
opcode < 255)
445445
{
446446
return true;
447447
}

0 commit comments

Comments
 (0)