You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Track grammar "stmt" simplifications class ...
* NAME_MODULE constant * QUAL_NAME constant
This commit is contained in:
@@ -32,14 +32,16 @@ SKIP_TESTS=(
|
||||
[test_doctest2.py]=1 # FIXME: assert failure - works on decompyle3
|
||||
[test_docxmlrpc.py]=1
|
||||
[test_enum.py]=1 # probably bad control flow
|
||||
|
||||
[test_faulthandler.py]=1 # takes too long
|
||||
[test_fcntl.py]=1
|
||||
[test_fileinput.py]=1 # Test assertion failures
|
||||
[test_format.py]=1 # Probably not handling bytestrings properly
|
||||
[test_frame.py]=1 # test assertion errors
|
||||
[test_ftplib.py]=1 # parse error
|
||||
[test_functools.py]=1 # parse error
|
||||
[test_fstring.py]=1 # need to disambiguate leading fstrings from docstrings
|
||||
[test_functools.py]=1 # parse error
|
||||
|
||||
[test_gdb.py]=1 # it fails on its own
|
||||
[test_generators.py]=1 # Investigate improper lamdba with bogus "False" added
|
||||
[test_glob.py]=1 # TypeError: join() argument must be str or bytes, not 'tuple'
|
||||
|
@@ -1,6 +1,8 @@
|
||||
SKIP_TESTS=(
|
||||
[test___all__.py]=1 # it fails on its own
|
||||
[test_aifc.py]=1 # parse error
|
||||
[test_argparse.py]=1 #- it fails on its own
|
||||
[test_array.py]=1 #- parse error
|
||||
[test_asdl_parser.py]=1 # it fails on its own
|
||||
[test_ast.py]=1 # Depends on comments in code
|
||||
[test_atexit.py]=1 # The atexit test looks for specific comments in error lines
|
||||
@@ -14,9 +16,9 @@ SKIP_TESTS=(
|
||||
[test_cmath.py]=1 # test assertion failure
|
||||
[test_cmd_line.py]=1 # Interactive?
|
||||
[test_cmd_line_script.py]=1
|
||||
[test_codecs.py]=1
|
||||
[test_collections.py]=1
|
||||
[test_compare.py]=1
|
||||
[test_compileall.py]=1 # fails on its own
|
||||
[test_compile.py]=1
|
||||
[test_concurrent_futures.py]=1 # too long
|
||||
[test_configparser.py]=1
|
||||
|
@@ -136,25 +136,25 @@ PASS = SyntaxTree('stmts',
|
||||
[ SyntaxTree('pass', [])])])])
|
||||
|
||||
ASSIGN_DOC_STRING = lambda doc_string, doc_load: \
|
||||
SyntaxTree('stmt',
|
||||
[ SyntaxTree('assign',
|
||||
[ SyntaxTree('expr', [ Token(doc_load, pattr=doc_string, attr=doc_string) ]),
|
||||
SyntaxTree('store', [ Token('STORE_NAME', pattr='__doc__')])
|
||||
SyntaxTree("stmt",
|
||||
[ SyntaxTree("assign",
|
||||
[ SyntaxTree("expr", [ Token(doc_load, pattr=doc_string, attr=doc_string) ]),
|
||||
SyntaxTree("store", [ Token("STORE_NAME", pattr="__doc__")])
|
||||
])])
|
||||
|
||||
NAME_MODULE = SyntaxTree('stmt',
|
||||
[ SyntaxTree('assign',
|
||||
[ SyntaxTree('expr',
|
||||
[Token('LOAD_NAME', pattr='__name__', offset=0, has_arg=True)]),
|
||||
SyntaxTree('store',
|
||||
[ Token('STORE_NAME', pattr='__module__', offset=3, has_arg=True)])
|
||||
NAME_MODULE = SyntaxTree("sstmt",
|
||||
[ SyntaxTree("assign",
|
||||
[ SyntaxTree("expr",
|
||||
[Token("LOAD_NAME", pattr="__name__", offset=0, has_arg=True)]),
|
||||
SyntaxTree("store",
|
||||
[ Token("STORE_NAME", pattr="__module__", offset=3, has_arg=True)])
|
||||
])])
|
||||
|
||||
# God intended \t, but Python has decided to use 4 spaces.
|
||||
# If you want real tabs, use Go.
|
||||
# TAB = '\t'
|
||||
TAB = ' ' * 4
|
||||
INDENT_PER_LEVEL = ' ' # additional intent per pretty-print level
|
||||
# TAB = "\t"
|
||||
TAB = " " * 4
|
||||
INDENT_PER_LEVEL = " " # additional intent per pretty-print level
|
||||
|
||||
TABLE_R = {
|
||||
'STORE_ATTR': ( '%c.%[1]{pattr}', 0),
|
||||
|
@@ -2115,7 +2115,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
try:
|
||||
self.write(eval(expr, d, d))
|
||||
except:
|
||||
from trepan.api import debug; debug()
|
||||
raise
|
||||
m = escape.search(fmt, i)
|
||||
self.write(fmt[i:])
|
||||
@@ -2272,13 +2271,13 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.println(self.traverse(ast[0]))
|
||||
del ast[0]
|
||||
|
||||
first_stmt = ast[0][0]
|
||||
first_stmt = ast[0]
|
||||
if 3.0 <= self.version <= 3.3:
|
||||
try:
|
||||
if first_stmt[0] == "store_locals":
|
||||
if first_stmt == "store_locals":
|
||||
if self.hide_internal:
|
||||
del ast[0]
|
||||
first_stmt = ast[0][0]
|
||||
first_stmt = ast[0]
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -2286,7 +2285,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
if first_stmt == NAME_MODULE:
|
||||
if self.hide_internal:
|
||||
del ast[0]
|
||||
first_stmt = ast[0][0]
|
||||
first_stmt = ast[0]
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
@@ -2296,9 +2295,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
# Should we ditch this in favor of the "else" case?
|
||||
qualname = ".".join(self.classes)
|
||||
QUAL_NAME = SyntaxTree(
|
||||
"stmt",
|
||||
[
|
||||
SyntaxTree(
|
||||
"assign",
|
||||
[
|
||||
SyntaxTree("expr", [Token("LOAD_CONST", pattr=qualname)]),
|
||||
@@ -2307,8 +2303,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
have_qualname = ast[0][0] == QUAL_NAME
|
||||
else:
|
||||
# Python 3.4+ has constants like 'cmp_to_key.<locals>.K'
|
||||
|
Reference in New Issue
Block a user