Skip to content

Commit 7755563

Browse files
committed
Some Python 3.6 bytecode->wordcode fixes
1 parent b43cbc0 commit 7755563

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

uncompyle6/scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def op_size(self, op):
228228
if op < self.opc.HAVE_ARGUMENT:
229229
return 1
230230
else:
231-
return 3
231+
return 2 if self.version >= 3.6 else 3
232232

233233
def remove_mid_line_ifs(self, ifs):
234234
"""

uncompyle6/scanners/scanner3.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,15 @@ def get_target(self, offset):
562562
Get target offset for op located at given <offset>.
563563
"""
564564
op = self.code[offset]
565-
target = self.code[offset+1] + self.code[offset+2] * 256
566-
if op in op3.hasjrel:
567-
target += offset + 3
565+
if self.version >= 3.6:
566+
target = self.code[offset+1]
567+
if op in op3.hasjrel:
568+
target += offset + 2
569+
else:
570+
target = self.code[offset+1] + self.code[offset+2] * 256
571+
if op in op3.hasjrel:
572+
target += offset + 3
573+
568574
return target
569575

570576
def detect_structure(self, offset, targets):
@@ -678,6 +684,11 @@ def detect_structure(self, offset, targets):
678684
# rocky: if we have a conditional jump to the next instruction, then
679685
# possibly I am "skipping over" a "pass" or null statement.
680686

687+
try:
688+
code[prev_op[target]]
689+
except:
690+
from trepan.api import debug; debug()
691+
681692
if ((code[prev_op[target]] in self.pop_jump_if_pop) and
682693
(target > offset) and prev_op[target] != offset):
683694
self.fixed_jumps[offset] = prev_op[target]

0 commit comments

Comments
 (0)