diff --git a/pytest/test_fjt.py b/pytest/test_fjt.py index cadfd31b..28cb2a7e 100644 --- a/pytest/test_fjt.py +++ b/pytest/test_fjt.py @@ -41,7 +41,7 @@ def test_if_in_for(): scan.build_lines_data(code, n) scan.build_prev_op(n) fjt = scan.find_jump_targets(False) - assert{64: [42], 67: [42], 42: [16, 41], 19: [6]} == fjt + assert{64: [42], 67: [42, 42], 42: [16, 41], 19: [6]} == fjt assert scan.structs == [ {'start': 0, 'end': 80, 'type': 'root'}, {'start': 3, 'end': 64, 'type': 'if-then'}, diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index e20f5a95..2c8d1298 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -45,7 +45,10 @@ class Python27Parser(Python2Parser): def p_jump27(self, args): """ - _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM + come_froms ::= come_froms COME_FROM + come_froms ::= COME_FROM + + _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD come_froms bp_come_from ::= POP_BLOCK COME_FROM # FIXME: Common with 3.0+ diff --git a/uncompyle6/scanners/scanner2.py b/uncompyle6/scanners/scanner2.py index 1a2ff967..877f5170 100644 --- a/uncompyle6/scanners/scanner2.py +++ b/uncompyle6/scanners/scanner2.py @@ -875,8 +875,9 @@ class Scanner2(scan.Scanner): oparg = self.get_argument(offset) if label is None: - if (op in self.opc.hasjrel and - (self.version < 2.0 or op != self.opc.FOR_ITER)): + if op in self.opc.hasjrel and self.opc.opname[op] != 'FOR_ITER': + # if (op in self.opc.hasjrel and + # (self.version < 2.0 or op != self.opc.FOR_ITER)): label = offset + 3 + oparg elif self.version == 2.7 and op in self.opc.hasjabs: if op in (self.opc.JUMP_IF_FALSE_OR_POP, @@ -906,7 +907,7 @@ class Scanner2(scan.Scanner): and code[offset+4] == self.opc.END_FINALLY))): # FIXME: rocky: I think we need something like this... - if offset not in set(self.ignore_if): + if offset not in set(self.ignore_if) or self.version == 2.7: source = (self.setup_loops[label] if label in self.setup_loops else offset) targets[label] = targets.get(label, []) + [source] @@ -922,6 +923,7 @@ class Scanner2(scan.Scanner): # DEBUG: if debug in ('both', 'after'): + print(targets) import pprint as pp pp.pprint(self.structs)