]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-112355: fix calculation of jump target of ENTER_EXECUTOR in dis (#112377)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Fri, 24 Nov 2023 18:13:25 +0000 (18:13 +0000)
committerGitHub <noreply@github.com>
Fri, 24 Nov 2023 18:13:25 +0000 (18:13 +0000)
Lib/dis.py

index c8313ac15a05c1791ce478c27b3250386b7c5e37..e08e9a94057689334b9aa0a7155b76f1cee3c586 100644 (file)
@@ -30,6 +30,7 @@ CONVERT_VALUE = opmap['CONVERT_VALUE']
 SET_FUNCTION_ATTRIBUTE = opmap['SET_FUNCTION_ATTRIBUTE']
 FUNCTION_ATTR_FLAGS = ('defaults', 'kwdefaults', 'annotations', 'closure')
 
+ENTER_EXECUTOR = opmap['ENTER_EXECUTOR']
 LOAD_CONST = opmap['LOAD_CONST']
 RETURN_CONST = opmap['RETURN_CONST']
 LOAD_GLOBAL = opmap['LOAD_GLOBAL']
@@ -373,6 +374,8 @@ class Instruction(_Instruction):
                 argval = offset + 2 + signed_arg*2
                 caches = _get_cache_size(_all_opname[deop])
                 argval += 2 * caches
+                if deop == ENTER_EXECUTOR:
+                    argval += 2
                 argrepr = f"to L{labels_map[argval]}"
             elif deop in (LOAD_FAST_LOAD_FAST, STORE_FAST_LOAD_FAST, STORE_FAST_STORE_FAST):
                 arg1 = arg >> 4
@@ -605,7 +608,9 @@ def _parse_exception_table(code):
         return entries
 
 def _is_backward_jump(op):
-    return 'JUMP_BACKWARD' in opname[op]
+    return opname[op] in ('JUMP_BACKWARD',
+                          'JUMP_BACKWARD_NO_INTERRUPT',
+                          'ENTER_EXECUTOR')
 
 def _get_instructions_bytes(code, varname_from_oparg=None,
                             names=None, co_consts=None,