diff --git a/test/bytecode_3.4/10_try_continue_bug.pyc b/test/bytecode_3.4/10_try_continue_bug.pyc new file mode 100644 index 00000000..5c4a3128 Binary files /dev/null and b/test/bytecode_3.4/10_try_continue_bug.pyc differ diff --git a/test/simple_source/exception/10_try_continue_bug.py b/test/simple_source/exception/10_try_continue_bug.py new file mode 100644 index 00000000..40eb52a9 --- /dev/null +++ b/test/simple_source/exception/10_try_continue_bug.py @@ -0,0 +1,19 @@ +# Python 3.4 bug found from tempfile.py +def _get_default_tempdir(dirlist, fd): + for dir in dirlist: + for seq in range(100): + try: + try: + try: + with open(fd, 'wb', closefd=False) as fp: + fp.write(b'blat') + finally: + seq += 1 + finally: + seq += 10 + return dir + except RuntimeError: + pass + except OSError: + break # no point trying more names in this directory + raise RuntimeError diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 345617d8..54040d9a 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -265,8 +265,11 @@ class Python3Parser(PythonParser): except_stmt ::= except_pop_except # Python3 introduced POP_EXCEPT - except_suite ::= c_stmts_opt POP_EXCEPT JUMP_FORWARD - except_suite ::= c_stmts_opt POP_EXCEPT jmp_abs + except_suite ::= c_stmts_opt POP_EXCEPT jump_except + jump_except ::= JUMP_ABSOLUTE + jump_except ::= JUMP_BACK + jump_except ::= JUMP_FORWARD + jump_except ::= CONTINUE # This is used in Python 3 in # "except ... as e" to remove 'e' after the c_stmts_opt finishes @@ -287,11 +290,9 @@ class Python3Parser(PythonParser): except ::= POP_TOP POP_TOP POP_TOP c_stmts_opt POP_EXCEPT _jump except ::= POP_TOP POP_TOP POP_TOP return_stmts - jmp_abs ::= JUMP_ABSOLUTE jmp_abs ::= JUMP_BACK - withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY