diff --git a/pytest/test_grammar.py b/pytest/test_grammar.py index d9d23a8b..c091bd6c 100644 --- a/pytest/test_grammar.py +++ b/pytest/test_grammar.py @@ -34,6 +34,7 @@ def test_grammar(): """ JUMP_BACK CONTINUE RETURN_END_IF COME_FROM COME_FROM_EXCEPT COME_FROM_LOOP COME_FROM_WITH + COME_FROM_FINALLY LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LAMBDA_MARKER RETURN_LAST """.split()) diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 70c46a7e..7db37341 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -158,7 +158,7 @@ class Python3Parser(PythonParser): # this is nested inside a trystmt tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt POP_BLOCK LOAD_CONST - COME_FROM suite_stmts_opt END_FINALLY + come_from_or_finally suite_stmts_opt END_FINALLY tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle else_suite come_froms @@ -203,8 +203,8 @@ class Python3Parser(PythonParser): except_suite_finalize ::= SETUP_FINALLY c_stmts_opt except_var_finalize END_FINALLY _jump - except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST COME_FROM LOAD_CONST - designator del_stmt + except_var_finalize ::= POP_BLOCK POP_EXCEPT LOAD_CONST come_from_or_finally + LOAD_CONST designator del_stmt except_suite ::= return_stmts @@ -249,8 +249,12 @@ class Python3Parser(PythonParser): come_froms ::= come_froms COME_FROM come_froms ::= - opt_come_from_loop ::= _come_from COME_FROM_LOOP + opt_come_from_loop ::= opt_come_from_loop COME_FROM_LOOP opt_come_from_loop ::= + + come_from_or_finally ::= COME_FROM_FINALLY + come_from_or_finally ::= COME_FROM + """ def p_jump3(self, args): @@ -294,8 +298,12 @@ class Python3Parser(PythonParser): forelselaststmtl ::= SETUP_LOOP expr _for designator for_block POP_BLOCK else_suitel COME_FROM_LOOP + whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM_LOOP + whilestmt ::= SETUP_LOOP testexpr return_stmts POP_BLOCK + COME_FROM_LOOP + whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK else_suite COME_FROM_LOOP whileelselaststmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK diff --git a/uncompyle6/scanners/scanner3.py b/uncompyle6/scanners/scanner3.py index 556aa5ac..1c379562 100644 --- a/uncompyle6/scanners/scanner3.py +++ b/uncompyle6/scanners/scanner3.py @@ -208,12 +208,9 @@ class Scanner3(Scanner): come_from_name = 'COME_FROM' if (inst.offset in offset_action): action = offset_action[inst.offset] - if (action.type == 'end' + if (action.type == 'end' and (self.opName(jump_offset)[len('SETUP_'):] - == action.name) - # After the grammar is fully adjusted, remove the below - # test - and action.name in ['EXCEPT', 'LOOP', 'WITH']): + == action.name)): come_from_name = '%s_%s' % ( (come_from_name, action.name)) pass