summaryrefslogtreecommitdiff
path: root/Lib/dis.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index 355f468301..bd87de97fc 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -37,6 +37,7 @@ LOAD_CONST = opmap['LOAD_CONST']
LOAD_GLOBAL = opmap['LOAD_GLOBAL']
BINARY_OP = opmap['BINARY_OP']
JUMP_BACKWARD = opmap['JUMP_BACKWARD']
+FOR_ITER = opmap['FOR_ITER']
LOAD_ATTR = opmap['LOAD_ATTR']
CACHE = opmap["CACHE"]
@@ -476,6 +477,8 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
elif deop in hasjrel:
signed_arg = -arg if _is_backward_jump(deop) else arg
argval = offset + 2 + signed_arg*2
+ if deop == FOR_ITER:
+ argval += 2
argrepr = "to " + repr(argval)
elif deop in haslocal or deop in hasfree:
argval, argrepr = _get_name_info(arg, varname_from_oparg)
@@ -629,11 +632,14 @@ def findlabels(code):
labels = []
for offset, op, arg in _unpack_opargs(code):
if arg is not None:
- if op in hasjrel:
- if _is_backward_jump(op):
+ deop = _deoptop(op)
+ if deop in hasjrel:
+ if _is_backward_jump(deop):
arg = -arg
label = offset + 2 + arg*2
- elif op in hasjabs:
+ if deop == FOR_ITER:
+ label += 2
+ elif deop in hasjabs:
label = arg*2
else:
continue