diff --git a/test/bytecode_3.0/01_comprehension.pyc b/test/bytecode_3.0/01_comprehension.pyc new file mode 100644 index 00000000..93c43e16 Binary files /dev/null and b/test/bytecode_3.0/01_comprehension.pyc differ diff --git a/uncompyle6/parsers/parse30.py b/uncompyle6/parsers/parse30.py index de810223..4c73f616 100644 --- a/uncompyle6/parsers/parse30.py +++ b/uncompyle6/parsers/parse30.py @@ -43,8 +43,16 @@ class Python30Parser(Python31Parser): set_comp_func ::= set_comp_func_header LOAD_FAST FOR_ITER store comp_iter JUMP_BACK POP_TOP JUMP_BACK RETURN_VALUE RETURN_LAST + + list_comp_header ::= BUILD_LIST_0 DUP_TOP STORE_FAST + list_comp ::= list_comp_header + LOAD_FAST FOR_ITER store comp_iter + JUMP_BACK + + comp_if ::= expr jmp_false comp_iter comp_iter ::= expr expr SET_ADD + comp_iter ::= expr expr LIST_APPEND # In many ways 3.0 is like 2.6. The below rules in fact are the same or similar. diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 5b577a37..f0e03fbb 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1052,7 +1052,8 @@ class SourceWalker(GenericASTTraversal, object): ast = ast[0] store = None - if ast in ['set_comp_func', 'dict_comp_func', 'set_comp_func_header']: + if ast in ['set_comp_func', 'dict_comp_func', + 'list_comp', 'set_comp_func_header']: for k in ast: if k == 'comp_iter': n = k @@ -1125,7 +1126,7 @@ class SourceWalker(GenericASTTraversal, object): self.write(' in ') self.preorder(node[-3]) - if ast == 'list_comp': + if ast == 'list_comp' and self.version != 3.0: list_iter = ast[1] assert list_iter == 'list_iter' if list_iter == 'list_for':