diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index 81dca720..05e89be7 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -179,6 +179,9 @@ class Python2Parser(PythonParser): tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle else_suitel COME_FROM + trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK + try_middle COME_FROM + except_stmts ::= except_stmts except_stmt except_stmts ::= except_stmt diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 199c7293..10de6bff 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -38,11 +38,21 @@ class Python26Parser(Python2Parser): """ + def p_whilestmt(self, args): + """ + whilestmt ::= SETUP_LOOP + testexpr + l_stmts_opt jb_pop + POP_BLOCK _come_from + + """ + def p_misc26(self, args): """ jmp_true ::= JUMP_IF_TRUE POP_TOP jmp_false ::= JUMP_IF_FALSE POP_TOP jf_pop ::= JUMP_FORWARD POP_TOP + jb_pop ::= JUMP_BACK POP_TOP _ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM """ diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 2a0e132c..2a3ccdc0 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -10,9 +10,6 @@ class Python27Parser(Python2Parser): def p_try27(self, args): """ - trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK - try_middle COME_FROM - try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM try_middle ::= jmp_abs COME_FROM except_stmts diff --git a/uncompyle6/scanners/scanner2.py b/uncompyle6/scanners/scanner2.py index 1c00120c..070ccffe 100755 --- a/uncompyle6/scanners/scanner2.py +++ b/uncompyle6/scanners/scanner2.py @@ -704,6 +704,10 @@ class Scanner2(scan.Scanner): if op in (self.opc.JUMP_IF_FALSE_OR_POP, self.opc.JUMP_IF_TRUE_OR_POP): if (oparg > i): label = oparg + elif self.version < 2.7 and op in self.opc.hasjabs: + if op in (self.opc.JUMP_IF_FALSE, self.opc.JUMP_IF_TRUE): + if (oparg > i): + label = oparg if label is not None and label != -1: targets[label] = targets.get(label, []) + [i]