summaryrefslogtreecommitdiffstats
path: root/Lib/dis.py
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2021-04-01 15:00:31 (GMT)
committerGitHub <noreply@github.com>2021-04-01 15:00:31 (GMT)
commitfcb55c0037baab6f98f91ee38ce84b6f874f034a (patch)
tree29e1499f2f77ad8a4c76d5484517f46ac4fe8313 /Lib/dis.py
parent2ac0515027699b5694d9a6ff40f1ddaba82c74c2 (diff)
downloadcpython-fcb55c0037baab6f98f91ee38ce84b6f874f034a.zip
cpython-fcb55c0037baab6f98f91ee38ce84b6f874f034a.tar.gz
cpython-fcb55c0037baab6f98f91ee38ce84b6f874f034a.tar.bz2
bpo-27129: Use instruction offsets, not byte offsets, in bytecode and internally. (GH-25069)
* Use instruction offset, rather than bytecode offset. Streamlines interpreter dispatch a bit, and removes most EXTENDED_ARGs for jumps. * Change some uses of PyCode_Addr2Line to PyFrame_GetLineNumber
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index ccbd65b..3fee1ce 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -338,8 +338,11 @@ def _get_instructions_bytes(code, varnames=None, names=None, constants=None,
argval, argrepr = _get_const_info(arg, constants)
elif op in hasname:
argval, argrepr = _get_name_info(arg, names)
+ elif op in hasjabs:
+ argval = arg*2
+ argrepr = "to " + repr(argval)
elif op in hasjrel:
- argval = offset + 2 + arg
+ argval = offset + 2 + arg*2
argrepr = "to " + repr(argval)
elif op in haslocal:
argval, argrepr = _get_name_info(arg, varnames)
@@ -437,9 +440,9 @@ def findlabels(code):
for offset, op, arg in _unpack_opargs(code):
if arg is not None:
if op in hasjrel:
- label = offset + 2 + arg
+ label = offset + 2 + arg*2
elif op in hasjabs:
- label = arg
+ label = arg*2
else:
continue
if label not in labels: