diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-04-11 09:40:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-11 09:40:24 (GMT) |
commit | dd207a6ac52d4bd9a71cf178fc1d5c17a6f07aff (patch) | |
tree | c196769c21e856595b8c90adc5205b2372234f02 /Lib/dis.py | |
parent | 98ff4a68773c49619d486c7e758ebbe1662f8387 (diff) | |
download | cpython-dd207a6ac52d4bd9a71cf178fc1d5c17a6f07aff.zip cpython-dd207a6ac52d4bd9a71cf178fc1d5c17a6f07aff.tar.gz cpython-dd207a6ac52d4bd9a71cf178fc1d5c17a6f07aff.tar.bz2 |
bpo-47120: make POP_JUMP_IF_TRUE/FALSE/NONE/NOT_NONE relative (GH-32400)
Diffstat (limited to 'Lib/dis.py')
-rw-r--r-- | Lib/dis.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -392,6 +392,9 @@ def parse_exception_table(code): except StopIteration: return entries +def _is_backward_jump(op): + return 'JUMP_BACKWARD' in opname[op] + def _get_instructions_bytes(code, varname_from_oparg=None, names=None, co_consts=None, linestarts=None, line_offset=0, @@ -442,7 +445,7 @@ def _get_instructions_bytes(code, varname_from_oparg=None, argval = arg*2 argrepr = "to " + repr(argval) elif op in hasjrel: - signed_arg = -arg if op == JUMP_BACKWARD else arg + signed_arg = -arg if _is_backward_jump(op) else arg argval = offset + 2 + signed_arg*2 argrepr = "to " + repr(argval) elif op in haslocal or op in hasfree: @@ -568,7 +571,7 @@ def findlabels(code): for offset, op, arg in _unpack_opargs(code): if arg is not None: if op in hasjrel: - if op == JUMP_BACKWARD: + if _is_backward_jump(op): arg = -arg label = offset + 2 + arg*2 elif op in hasjabs: |