diff --git a/uncompyle6/parsers/parse30.py b/uncompyle6/parsers/parse30.py index 0bb0de99..721e0740 100644 --- a/uncompyle6/parsers/parse30.py +++ b/uncompyle6/parsers/parse30.py @@ -34,6 +34,7 @@ class Python30Parser(Python31Parser): ifelsestmtl ::= testexpr c_stmts_opt jb_pop_top else_suitel iflaststmtl ::= testexpr c_stmts_opt jb_pop_top + iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE POP_TOP withasstmt ::= expr setupwithas store suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM_FINALLY @@ -76,8 +77,10 @@ class Python30Parser(Python31Parser): def customize_grammar_rules(self, tokens, customize): super(Python30Parser, self).customize_grammar_rules(tokens, customize) self.remove_rules(""" - iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK COME_FROM_LOOP - ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel + iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK COME_FROM_LOOP + ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel + iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE + _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_froms jump_forward_else ::= JUMP_FORWARD ELSE jump_absolute_else ::= JUMP_ABSOLUTE ELSE whilestmt ::= SETUP_LOOP testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK diff --git a/uncompyle6/scanners/scanner3.py b/uncompyle6/scanners/scanner3.py index 50425844..cc4c2058 100644 --- a/uncompyle6/scanners/scanner3.py +++ b/uncompyle6/scanners/scanner3.py @@ -73,8 +73,10 @@ class Scanner3(Scanner): if self.version == 3.0: self.pop_jump_tf = frozenset([self.opc.JUMP_IF_FALSE, self.opc.JUMP_IF_TRUE]) + self.not_continue_follow = ('END_FINALLY', 'POP_BLOCK', 'POP_TOP') else: self.pop_jump_tf = frozenset([self.opc.PJIF, self.opc.PJIT]) + self.not_continue_follow = ('END_FINALLY', 'POP_BLOCK') self.setup_ops_no_loop = frozenset(setup_ops) - frozenset([self.opc.SETUP_LOOP]) @@ -387,13 +389,9 @@ class Scanner3(Scanner): .opname == 'FOR_ITER' and self.insts[i+1].opname == 'JUMP_FORWARD') - if (is_continue or - (inst.offset in self.stmts and - (self.version != 3.0 or (hasattr(inst, 'linestart'))) and - (next_opname not in ('END_FINALLY', 'POP_BLOCK', - # Python 3.0 only uses POP_TOP - 'POP_TOP')))): + (inst.offset in self.stmts and (inst.starts_line and + next_opname not in self.not_continue_follow))): opname = 'CONTINUE' else: opname = 'JUMP_BACK'