diff --git a/test/bytecode_2.7/03_for_try_raise.pyc b/test/bytecode_2.7/03_for_try_raise.pyc new file mode 100644 index 00000000..aa3b668f Binary files /dev/null and b/test/bytecode_2.7/03_for_try_raise.pyc differ diff --git a/test/simple_source/bug27+/03_for_try_raise.py b/test/simple_source/bug27+/03_for_try_raise.py new file mode 100644 index 00000000..72ed5c3d --- /dev/null +++ b/test/simple_source/bug27+/03_for_try_raise.py @@ -0,0 +1,12 @@ +# Code in 2.7 needing rule: +# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK except_handler +# Generally we need a COME_FROM. But not in the situation below. + +for package in [1,2]: + try: + pass + except IndexError: + with __file__ as f: + pass + except: + raise diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 5ac9c73c..78f48755 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -51,6 +51,10 @@ class Python27Parser(Python2Parser): def p_try27(self, args): """ + # If the last except is a "raise" we might not have a final COME_FROM + try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK + except_handler + tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM_FINALLY suite_stmts_opt END_FINALLY @@ -144,6 +148,8 @@ class Python27Parser(Python2Parser): while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM while1stmt ::= SETUP_LOOP l_stmts_opt CONTINUE COME_FROM while1stmt ::= SETUP_LOOP returns COME_FROM + while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK + else_suitel COME_FROM while1stmt ::= SETUP_LOOP returns bp_come_from while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM