diff --git a/test/bytecode_3.6/04_try_finally.pyc b/test/bytecode_3.6/04_try_finally.pyc index 15a5adfb..8f7ab09f 100644 Binary files a/test/bytecode_3.6/04_try_finally.pyc and b/test/bytecode_3.6/04_try_finally.pyc differ diff --git a/test/bytecode_3.6/05_if_and_comp.pyc b/test/bytecode_3.6/05_if_and_comp.pyc index 48441fd6..1c05bcc4 100644 Binary files a/test/bytecode_3.6/05_if_and_comp.pyc and b/test/bytecode_3.6/05_if_and_comp.pyc differ diff --git a/test/simple_source/bug36/04_try_finally.py b/test/simple_source/bug36/04_try_finally.py index 4e0a5a61..1b2d2e49 100644 --- a/test/simple_source/bug36/04_try_finally.py +++ b/test/simple_source/bug36/04_try_finally.py @@ -18,3 +18,16 @@ def getvalue1(self): finally: pass return 2 + +# From Python 3.6 asynchat.py +# Bug is handling as why in the face of a return. +# uncompyle6 shows removal of "why" after the return. +def handle_read(self): + try: + data = 5 + except ZeroDivisionError: + return + except OSError as why: + return why + + return data diff --git a/test/simple_source/bug36/05_if_and_comp.py b/test/simple_source/bug36/05_if_and_comp.py index 46efdcb2..9c4bc61d 100644 --- a/test/simple_source/bug36/05_if_and_comp.py +++ b/test/simple_source/bug36/05_if_and_comp.py @@ -5,3 +5,8 @@ def _85encode(foldnuls, words): return ['z' if foldnuls and word else 'y' for word in words] + +# From Python 3.6 enum.py + +def __new__(metacls, cls, bases, classdict): + {k: classdict[k] for k in classdict._member_names} diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index cd3fb13b..a20e671e 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -240,10 +240,10 @@ class Python3Parser(PythonParser): except_suite ::= returns except_cond1 ::= DUP_TOP expr COMPARE_OP - jmp_false POP_TOP POP_TOP POP_TOP + jmp_false POP_TOP POP_TOP POP_TOP except_cond2 ::= DUP_TOP expr COMPARE_OP - jmp_false POP_TOP store POP_TOP + jmp_false POP_TOP store POP_TOP except ::= POP_TOP POP_TOP POP_TOP c_stmts_opt POP_EXCEPT _jump except ::= POP_TOP POP_TOP POP_TOP returns diff --git a/uncompyle6/parsers/parse36.py b/uncompyle6/parsers/parse36.py index 0391833c..18815bb3 100644 --- a/uncompyle6/parsers/parse36.py +++ b/uncompyle6/parsers/parse36.py @@ -33,9 +33,12 @@ class Python36Parser(Python35Parser): """ sstmt ::= sstmt RETURN_LAST - # 3.6 redoes how return_closure works + # 3.6 redoes how return_closure works. FIXME: Isolate to LOAD_CLOSURE return_closure ::= LOAD_CLOSURE DUP_TOP STORE_NAME RETURN_VALUE RETURN_LAST + # Is there something general going on here? FIXME: Isolate to LOAD_DICTCOMP + dict_comp ::= load_closure LOAD_DICTCOMP LOAD_CONST MAKE_FUNCTION_8 expr GET_ITER CALL_FUNCTION_1 + stmt ::= conditional_lambda conditional_lambda ::= expr jmp_false expr return_if_lambda return_stmt_lambda LAMBDA_MARKER @@ -78,6 +81,8 @@ class Python36Parser(Python35Parser): COME_FROM_FINALLY suite_stmts tryfinally36 ::= SETUP_FINALLY returns COME_FROM_FINALLY suite_stmts_opt END_FINALLY + except_suite_finalize ::= SETUP_FINALLY returns + COME_FROM_FINALLY suite_stmts_opt END_FINALLY _jump """ def customize_grammar_rules(self, tokens, customize):