[Python-checkins] gh-103082: use IS_VALID_OPCODE instead of _PyOpcode_OpName to check if an opcode is defined (#107882)

iritkatriel webhook-mailer at python.org
Mon Aug 14 05:51:54 EDT 2023


https://github.com/python/cpython/commit/608927b01447b110de5094271fbc4d49c60130b0
commit: 608927b01447b110de5094271fbc4d49c60130b0
branch: main
author: Irit Katriel <1055913+iritkatriel at users.noreply.github.com>
committer: iritkatriel <1055913+iritkatriel at users.noreply.github.com>
date: 2023-08-14T10:51:50+01:00
summary:

gh-103082: use IS_VALID_OPCODE instead of _PyOpcode_OpName to check if an opcode is defined (#107882)

files:
M Python/instrumentation.c

diff --git a/Python/instrumentation.c b/Python/instrumentation.c
index 6d11649c07fbe..b50e8e26476cd 100644
--- a/Python/instrumentation.c
+++ b/Python/instrumentation.c
@@ -7,6 +7,7 @@
 #include "pycore_namespace.h"
 #include "pycore_object.h"
 #include "pycore_opcode.h"
+#include "pycore_opcode_metadata.h" // IS_VALID_OPCODE
 #include "pycore_pyerrors.h"
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 
@@ -437,11 +438,10 @@ dump_instrumentation_data(PyCodeObject *code, int star, FILE*out)
 static bool
 valid_opcode(int opcode)
 {
-    if (opcode > 0 &&
+    if (IS_VALID_OPCODE(opcode) &&
+        opcode != CACHE &&
         opcode != RESERVED &&
-        opcode < 255 &&
-        _PyOpcode_OpName[opcode] &&
-        _PyOpcode_OpName[opcode][0] != '<')
+        opcode < 255)
     {
        return true;
     }



More information about the Python-checkins mailing list