Skip to content

Commit cd64156

Browse files
committed
Fix else detection bug in Python 3.6+
1 parent 3d49b49 commit cd64156

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

__pkginfo__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
]}
5858
ftp_url = None
5959
install_requires = ['spark-parser >= 1.8.7, < 1.9.0',
60-
'xdis >= 3.8.10, < 3.9.0']
60+
'xdis >= 3.9.0, < 3.10.0']
6161

6262
license = 'GPL3'
6363
mailing_list = '[email protected]'

uncompyle6/scanners/scanner3.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,9 @@ def detect_control_flow(self, offset, targets, inst_index):
609609
"""
610610

611611
code = self.code
612-
op = self.insts[inst_index].opcode
612+
inst = self.insts[inst_index]
613+
op = inst.opcode
614+
613615

614616
# Detect parent structure
615617
parent = self.structs[0]
@@ -632,7 +634,7 @@ def detect_control_flow(self, offset, targets, inst_index):
632634
# Try to find the jump_back instruction of the loop.
633635
# It could be a return instruction.
634636

635-
start += instruction_size(op, self.opc)
637+
start += inst.inst_size
636638
target = self.get_target(offset)
637639
end = self.restrict_to_parent(target, parent)
638640
self.setup_loops[target] = offset
@@ -718,8 +720,8 @@ def detect_control_flow(self, offset, targets, inst_index):
718720
'start': after_jump_offset,
719721
'end': end})
720722
elif op in self.pop_jump_tf:
721-
start = offset + instruction_size(op, self.opc)
722-
target = self.insts[inst_index].argval
723+
start = offset + inst.inst_size
724+
target = inst.argval
723725
rtarget = self.restrict_to_parent(target, parent)
724726
prev_op = self.prev_op
725727

@@ -757,7 +759,7 @@ def detect_control_flow(self, offset, targets, inst_index):
757759
pre_rtarget = prev_op[rtarget]
758760

759761
# Is it an "and" inside an "if" or "while" block
760-
if op == self.opc.POP_JUMP_IF_FALSE and self.version < 3.6:
762+
if op == self.opc.POP_JUMP_IF_FALSE:
761763

762764
# Search for another POP_JUMP_IF_FALSE targetting the same op,
763765
# in current statement, starting from current offset, and filter

0 commit comments

Comments
 (0)