diff --git a/uncompyle6/parsers/parse25.py b/uncompyle6/parsers/parse25.py index 195d15df..35915c58 100644 --- a/uncompyle6/parsers/parse25.py +++ b/uncompyle6/parsers/parse25.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Rocky Bernstein +# Copyright (c) 2016-2017 Rocky Bernstein """ spark grammar differences over Python2.6 for Python 2.5. """ @@ -20,6 +20,7 @@ class Python25Parser(Python26Parser): return_if_stmt ::= ret_expr RETURN_END_IF JUMP_BACK # Python 2.6 uses ROT_TWO instead of the STORE_xxx + # withas is allowed as a "from future" in 2.5 setupwithas ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 setup_finally diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index 0790fb1b..46b21037 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -251,8 +251,6 @@ TABLE_DIRECT = { 'except_cond1': ( '%|except %c:\n', 1 ), 'except_suite': ( '%+%c%-%C', 0, (1, maxint, '') ), 'except_suite_finalize': ( '%+%c%-%C', 1, (3, maxint, '') ), - 'withstmt': ( '%|with %c:\n%+%c%-', 0, 3), - 'withasstmt': ( '%|with %c as %c:\n%+%c%-', 0, 2, 3), 'passstmt': ( '%|pass\n', ), 'STORE_FAST': ( '%{pattr}', ), 'kv': ( '%c: %c', 3, 1 ), diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 6359b4a7..d893d7d2 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015, 2016 by Rocky Bernstein +# Copyright (c) 2015-2017 by Rocky Bernstein # Copyright (c) 2005 by Dan Pascu # Copyright (c) 2000-2002 by hartmut Goebel # Copyright (c) 1999 John Aycock @@ -241,6 +241,9 @@ class SourceWalker(GenericASTTraversal, object): TABLE_DIRECT.update({ 'importmultiple': ( '%|import %c%c\n', 2, 3 ), 'import_cont' : ( ', %c', 2 ), + # With/as is allowed as "from future" thing in 2.5 + 'withstmt': ( '%|with %c:\n%+%c%-', 0, 3), + 'withasstmt': ( '%|with %c as %c:\n%+%c%-', 0, 2, 3), }) ########################################