You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Keep pre-3.6 listcomp code patterns in 3.6
This commit is contained in:
Binary file not shown.
@@ -16,3 +16,9 @@ def __init__(self, path, name, files=(), dirs=(), volumes=()):
|
||||
for filename in files
|
||||
for drive in volumes]
|
||||
return f, f2
|
||||
|
||||
# From 3.6 codeop. The below listcomp is generated still
|
||||
# like it was in 3.5
|
||||
import __future__
|
||||
_features = [getattr(__future__, fname)
|
||||
for fname in __future__.all_feature_names]
|
||||
|
@@ -885,13 +885,15 @@ class Python3Parser(PythonParser):
|
||||
"GET_ITER CALL_FUNCTION_1" % ('pos_arg '* args_pos, opname))
|
||||
self.add_make_function_rule(rule_pat, opname, token.attr, customize)
|
||||
if is_pypy or (i >= 2 and tokens[i-2] == 'LOAD_LISTCOMP'):
|
||||
if self.version < 3.6:
|
||||
rule_pat = ("listcomp ::= %sLOAD_LISTCOMP %%s%s expr "
|
||||
"GET_ITER CALL_FUNCTION_1" % ('expr ' * args_pos, opname))
|
||||
else:
|
||||
# 3.6+ bundles all of the 'exprs' in the rule above into a tuple.
|
||||
rule_pat = ("listcomp ::= load_closure LOAD_LISTCOMP %%s%s expr "
|
||||
"GET_ITER CALL_FUNCTION_1" % (opname,))
|
||||
if self.version >= 3.6:
|
||||
# 3.6+ sometimes bundles all of the
|
||||
# 'exprs' in the rule above into a
|
||||
# tuple.
|
||||
rule_pat = ("listcomp ::= load_closure LOAD_LISTCOMP %%s%s "
|
||||
"expr GET_ITER CALL_FUNCTION_1" % (opname,))
|
||||
self.add_make_function_rule(rule_pat, opname, token.attr, customize)
|
||||
rule_pat = ("listcomp ::= %sLOAD_LISTCOMP %%s%s expr "
|
||||
"GET_ITER CALL_FUNCTION_1" % ('expr ' * args_pos, opname))
|
||||
self.add_make_function_rule(rule_pat, opname, token.attr, customize)
|
||||
|
||||
if is_pypy or (i >= 2 and tokens[i-2] == 'LOAD_LAMBDA'):
|
||||
|
@@ -1697,6 +1697,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
|
||||
assert n == 'lc_body', ast
|
||||
|
||||
# FIXME: add indentation around "for"'s and "in"'s
|
||||
self.preorder(n[0])
|
||||
if self.version < 3.6:
|
||||
self.write(' for ')
|
||||
|
Reference in New Issue
Block a user