You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Split out Python 3.1 parser from rest.
__pkginfo__.py: use Python 3.1 bytecode fixes
This commit is contained in:
@@ -38,7 +38,7 @@ entry_points={
|
|||||||
]}
|
]}
|
||||||
ftp_url = None
|
ftp_url = None
|
||||||
install_requires = ['spark-parser >= 1.4.0',
|
install_requires = ['spark-parser >= 1.4.0',
|
||||||
'xdis >= 3.1.0']
|
'xdis >= 3.2.0']
|
||||||
license = 'MIT'
|
license = 'MIT'
|
||||||
mailing_list = 'python-debugger@googlegroups.com'
|
mailing_list = 'python-debugger@googlegroups.com'
|
||||||
modname = 'uncompyle6'
|
modname = 'uncompyle6'
|
||||||
|
@@ -623,7 +623,8 @@ def get_python_parser(
|
|||||||
import uncompyle6.parsers.parse3 as parse3
|
import uncompyle6.parsers.parse3 as parse3
|
||||||
if version == 3.1:
|
if version == 3.1:
|
||||||
if compile_mode == 'exec':
|
if compile_mode == 'exec':
|
||||||
p = parse3.Python31Parser(debug_parser)
|
import uncompyle6.parsers.parse31 as parse31
|
||||||
|
p = parse31.Python31Parser(debug_parser)
|
||||||
else:
|
else:
|
||||||
p = parse3.Python31ParserSingle(debug_parser)
|
p = parse3.Python31ParserSingle(debug_parser)
|
||||||
elif version == 3.2:
|
elif version == 3.2:
|
||||||
|
@@ -693,40 +693,10 @@ class Python32Parser(Python3Parser):
|
|||||||
"""
|
"""
|
||||||
pass
|
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):
|
class Python3ParserSingle(Python3Parser, PythonParserSingle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Python31ParserSingle(Python31Parser, PythonParserSingle):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class Python32ParserSingle(Python32Parser, PythonParserSingle):
|
class Python32ParserSingle(Python32Parser, PythonParserSingle):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
40
uncompyle6/parsers/parse31.py
Normal file
40
uncompyle6/parsers/parse31.py
Normal file
@@ -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
|
Reference in New Issue
Block a user