diff --git a/test/bytecode_3.4/06_tryifelse.pyc b/test/bytecode_3.4/06_tryifelse.pyc new file mode 100644 index 00000000..046a0e03 Binary files /dev/null and b/test/bytecode_3.4/06_tryifelse.pyc differ diff --git a/test/simple_source/exception/06_tryifelse.py b/test/simple_source/exception/06_tryifelse.py new file mode 100644 index 00000000..4dcc66de --- /dev/null +++ b/test/simple_source/exception/06_tryifelse.py @@ -0,0 +1,11 @@ +# Bug from 3.4 in asyncore.py +def accept(): + try: + conn = 5 + except TypeError: + return None + except OSError as why: + if why == 6: + raise + else: + return conn diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index fd079a8e..3a226cfa 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -134,6 +134,16 @@ class PythonParser(GenericASTBuilder): jmp_false ::= JUMP_IF_FALSE jmp_true ::= POP_JUMP_IF_TRUE jmp_true ::= JUMP_IF_TRUE + + # Zero or more COME_FROM + # loops can have this + _come_from ::= _come_from COME_FROM + _come_from ::= + + # Zero or one COME_FROM + # And/or expressions have this + come_from_opt ::= COME_FROM + come_from_opt ::= """ def p_dictcomp(self, args): @@ -274,16 +284,6 @@ class PythonParser(GenericASTBuilder): list_iter ::= list_if_not list_iter ::= lc_body - # Zero or more COME_FROM - # loops can have this - _come_from ::= _come_from COME_FROM - _come_from ::= - - # Zero or one COME_FROM - # And/or expressions have this - come_from_opt ::= COME_FROM - come_from_opt ::= - list_if ::= expr jmp_false list_iter list_if_not ::= expr jmp_true list_iter diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 6f8da5e1..cfed1aa9 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -242,7 +242,7 @@ class Python3Parser(PythonParser): COME_FROM suite_stmts_opt END_FINALLY tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK - try_middle else_suite COME_FROM + try_middle else_suite come_froms tryelsestmtc ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle else_suitec COME_FROM @@ -307,6 +307,12 @@ class Python3Parser(PythonParser): try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY NOP COME_FROM """ + def p_jump3(self, args): + """ + come_froms ::= come_froms COME_FROM + come_froms ::= COME_FROM + """ + def p_stmt3(self, args): """ stmt ::= LOAD_CLOSURE RETURN_VALUE RETURN_LAST