diff --git a/__pkginfo__.py b/__pkginfo__.py index 2c211f66..72659671 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -38,7 +38,7 @@ entry_points={ ]} ftp_url = None install_requires = ['spark-parser >= 1.4.0', - 'xdis >= 3.1.0'] + 'xdis >= 3.2.0'] license = 'MIT' mailing_list = 'python-debugger@googlegroups.com' modname = 'uncompyle6' diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 1ab82008..5e6a0329 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -623,7 +623,8 @@ def get_python_parser( import uncompyle6.parsers.parse3 as parse3 if version == 3.1: if compile_mode == 'exec': - p = parse3.Python31Parser(debug_parser) + import uncompyle6.parsers.parse31 as parse31 + p = parse31.Python31Parser(debug_parser) else: p = parse3.Python31ParserSingle(debug_parser) elif version == 3.2: diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index e9d55199..da218ca4 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -693,40 +693,10 @@ class Python32Parser(Python3Parser): """ pass -class Python31Parser(Python32Parser): - - def p_31(self, args): - """ - binary_subscr2 ::= expr expr DUP_TOPX BINARY_SUBSCR - - setupwith ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 POP_TOP - setupwithas ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 store - withstmt ::= expr setupwith SETUP_FINALLY - suite_stmts_opt - POP_BLOCK LOAD_CONST COME_FROM_FINALLY - load del_stmt WITH_CLEANUP END_FINALLY - - # Keeps Python 3.1 withas desigator in the same position as it is in other version - setupwithas31 ::= setupwithas SETUP_FINALLY load del_stmt - - withasstmt ::= expr setupwithas31 designator - suite_stmts_opt - POP_BLOCK LOAD_CONST COME_FROM_FINALLY - load del_stmt WITH_CLEANUP END_FINALLY - - store ::= STORE_FAST - store ::= STORE_NAME - load ::= LOAD_FAST - load ::= LOAD_NAME - """ - class Python3ParserSingle(Python3Parser, PythonParserSingle): pass -class Python31ParserSingle(Python31Parser, PythonParserSingle): - pass - class Python32ParserSingle(Python32Parser, PythonParserSingle): pass diff --git a/uncompyle6/parsers/parse31.py b/uncompyle6/parsers/parse31.py new file mode 100644 index 00000000..1e615f9d --- /dev/null +++ b/uncompyle6/parsers/parse31.py @@ -0,0 +1,40 @@ +# Copyright (c) 2016 Rocky Bernstein +""" +spark grammar differences over Python 3.2 for Python 3.1. +""" +from __future__ import print_function + +from uncompyle6.parser import PythonParserSingle +from uncompyle6.parsers.parse3 import Python32Parser + +class Python31Parser(Python32Parser): + + def p_31(self, args): + """ + binary_subscr2 ::= expr expr DUP_TOPX BINARY_SUBSCR + + setupwith ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 POP_TOP + setupwithas ::= DUP_TOP LOAD_ATTR store LOAD_ATTR CALL_FUNCTION_0 store + withstmt ::= expr setupwith SETUP_FINALLY + suite_stmts_opt + POP_BLOCK LOAD_CONST COME_FROM_FINALLY + load del_stmt WITH_CLEANUP END_FINALLY + + # Keeps Python 3.1 withas desigator in the same position as it is in other version + setupwithas31 ::= setupwithas SETUP_FINALLY load del_stmt + + withasstmt ::= expr setupwithas31 designator + suite_stmts_opt + POP_BLOCK LOAD_CONST COME_FROM_FINALLY + load del_stmt WITH_CLEANUP END_FINALLY + + store ::= STORE_FAST + store ::= STORE_NAME + load ::= LOAD_FAST + load ::= LOAD_NAME + + funcdef ::= mkfunc designator + """ + +class Python31ParserSingle(Python31Parser, PythonParserSingle): + pass