diff --git a/test/bytecode_3.6/06_listcomp_nest.pyc b/test/bytecode_3.6/06_listcomp_nest.pyc index de374761..7873bf1e 100644 Binary files a/test/bytecode_3.6/06_listcomp_nest.pyc and b/test/bytecode_3.6/06_listcomp_nest.pyc differ diff --git a/test/simple_source/bug36/06_listcomp_nest.py b/test/simple_source/bug36/06_listcomp_nest.py index 1bd65360..99b4943c 100644 --- a/test/simple_source/bug36/06_listcomp_nest.py +++ b/test/simple_source/bug36/06_listcomp_nest.py @@ -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] diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 2b74a2d2..5f35d7e3 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -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'): diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 7cb908b8..b90760a5 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -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 ')