Skip to content

Commit

Permalink
pythongh-112355: fix calculation of jump target of ENTER_EXECUTOR in …
Browse files Browse the repository at this point in the history
…dis (python#112377)
  • Loading branch information
iritkatriel authored Nov 24, 2023
1 parent fafae08 commit 9eb3b35
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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']
Expand Down Expand Up @@ -373,6 +374,8 @@ def _get_argval_argrepr(op, arg, offset, co_consts, names, varname_from_oparg,
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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9eb3b35

Please sign in to comment.