diff --git a/test/bytecode_2.7/05_try_finally_pass.pyc b/test/bytecode_2.7/05_try_finally_pass.pyc new file mode 100644 index 00000000..6be3d50b Binary files /dev/null and b/test/bytecode_2.7/05_try_finally_pass.pyc differ diff --git a/test/bytecode_2.7/10_if_break_finally.pyc b/test/bytecode_2.7/10_if_break_finally.pyc new file mode 100644 index 00000000..457e93b4 Binary files /dev/null and b/test/bytecode_2.7/10_if_break_finally.pyc differ diff --git a/test/bytecode_3.5/05_try_finally_pass.pyc b/test/bytecode_3.5/05_try_finally_pass.pyc new file mode 100644 index 00000000..41aad59a Binary files /dev/null and b/test/bytecode_3.5/05_try_finally_pass.pyc differ diff --git a/test/bytecode_3.5/10_if_break_finally.pyc b/test/bytecode_3.5/10_if_break_finally.pyc new file mode 100644 index 00000000..ebf42bbd Binary files /dev/null and b/test/bytecode_3.5/10_if_break_finally.pyc differ diff --git a/test/simple_source/stmts/05_try_finally_pass.py b/test/simple_source/stmts/05_try_finally_pass.py new file mode 100644 index 00000000..c4f213e0 --- /dev/null +++ b/test/simple_source/stmts/05_try_finally_pass.py @@ -0,0 +1,10 @@ +# Tests and empty finally section +# tryfinallystmt ::= SETUP_FINALLY e_suite_stmts_opt +# POP_BLOCK LOAD_CONST COME_FROM e_suite_stmts_opt END_FINALLY +# + +try: + pass +finally: + pass +pass diff --git a/test/simple_source/stmts/10_if_break_finally.py b/test/simple_source/stmts/10_if_break_finally.py new file mode 100644 index 00000000..4a1486df --- /dev/null +++ b/test/simple_source/stmts/10_if_break_finally.py @@ -0,0 +1,10 @@ +# Tests +# while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM +# tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt POP_BLOCK + +try: + while 1: + if __file__: + break +finally: + pass diff --git a/uncompyle6/opcodes/opcode_27.py b/uncompyle6/opcodes/opcode_27.py index b4dbba3f..1fb748aa 100755 --- a/uncompyle6/opcodes/opcode_27.py +++ b/uncompyle6/opcodes/opcode_27.py @@ -215,6 +215,5 @@ del def_op, name_op, jrel_op, jabs_op from uncompyle6 import PYTHON_VERSION if PYTHON_VERSION == 2.7: import dis - # print(dis.opmap.items()) - print(set(dis.opmap.items()) - set(opmap.items())) + # print(set(dis.opmap.items()) - set(opmap.items())) assert all(item in opmap.items() for item in dis.opmap.items()) diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 44d0d189..a12720e6 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -448,7 +448,7 @@ def python_parser(version, co, out=sys.stdout, showasm=False, print(t) # For heavy grammar debugging - # parser_debug = {'rules': True, 'transition': True, 'reduce' : True} + parser_debug = {'rules': True, 'transition': True, 'reduce' : True} p = get_python_parser(version, parser_debug) return parse(p, tokens, customize) diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index 9484500c..49bac881 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -268,7 +268,7 @@ class Python2Parser(PythonParser): try_middle COME_FROM # this is nested inside a trystmt - tryfinallystmt ::= SETUP_FINALLY suite_stmts + tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM suite_stmts_opt END_FINALLY @@ -328,7 +328,10 @@ class Python2Parser(PythonParser): return_stmts POP_BLOCK COME_FROM + while1stmt_pre ::= SETUP_LOOP l_stmts JUMP_BACK while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM + while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM + while1stmt ::= SETUP_LOOP return_stmts COME_FROM while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 8424b26c..0533e499 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -263,7 +263,7 @@ class Python3Parser(PythonParser): try_middle _come_from _come_from # this is nested inside a trystmt - tryfinallystmt ::= SETUP_FINALLY suite_stmts + tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM suite_stmts_opt END_FINALLY