Skip to content

Commit bf58358

Browse files
committed
fix dis
1 parent 4213582 commit bf58358

File tree

2 files changed

+148
-142
lines changed

2 files changed

+148
-142
lines changed

Lib/dis.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
LOAD_GLOBAL = opmap['LOAD_GLOBAL']
3232
BINARY_OP = opmap['BINARY_OP']
3333
JUMP_BACKWARD = opmap['JUMP_BACKWARD']
34+
FOR_ITER = opmap['FOR_ITER']
3435

3536
CACHE = opmap["CACHE"]
3637

@@ -473,6 +474,8 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
473474
elif deop in hasjrel:
474475
signed_arg = -arg if _is_backward_jump(deop) else arg
475476
argval = offset + 2 + signed_arg*2
477+
if deop == FOR_ITER:
478+
argval += 2
476479
argrepr = "to " + repr(argval)
477480
elif deop in haslocal or deop in hasfree:
478481
argval, argrepr = _get_name_info(arg, varname_from_oparg)
@@ -596,11 +599,14 @@ def findlabels(code):
596599
labels = []
597600
for offset, op, arg in _unpack_opargs(code):
598601
if arg is not None:
599-
if op in hasjrel:
600-
if _is_backward_jump(op):
602+
deop = _deoptop(op)
603+
if deop in hasjrel:
604+
if _is_backward_jump(deop):
601605
arg = -arg
602606
label = offset + 2 + arg*2
603-
elif op in hasjabs:
607+
if deop == FOR_ITER:
608+
label += 2
609+
elif deop in hasjabs:
604610
label = arg*2
605611
else:
606612
continue

0 commit comments

Comments
 (0)