diff --git a/test/bytecode_2.6/08_for_if_for.pyc b/test/bytecode_2.6/08_for_if_for.pyc new file mode 100644 index 00000000..59f579dd Binary files /dev/null and b/test/bytecode_2.6/08_for_if_for.pyc differ diff --git a/test/simple_source/comprehension/08_for_if_for.py b/test/simple_source/comprehension/08_for_if_for.py new file mode 100644 index 00000000..f601d0e6 --- /dev/null +++ b/test/simple_source/comprehension/08_for_if_for.py @@ -0,0 +1,7 @@ +# from 2.6.9 ast +# Should see genexpr +rv = '%s(%s' % (node.__class__.__name__, ', '.join( + ('%s=%s' % field for field in fields) + if annotate_fields else + (b for a, b in fields) +)) diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 8bf9468d..8e85010e 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -74,6 +74,7 @@ class Python26Parser(Python2Parser): jb_cf_pop ::= JUMP_BACK come_froms POP_TOP ja_cf_pop ::= JUMP_ABSOLUTE come_from_pop + jf_cf_pop ::= JUMP_FORWARD come_from_pop _ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM come_from_pop @@ -133,6 +134,8 @@ class Python26Parser(Python2Parser): setup_loop_lf ::= SETUP_LOOP LOAD_FAST genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK POP_BLOCK COME_FROM genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK come_from_pop JUMP_BACK POP_BLOCK COME_FROM + genexpr ::= LOAD_GENEXPR MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1 COME_FROM + ''' def p_ret26(self, args): @@ -153,7 +156,10 @@ class Python26Parser(Python2Parser): except_suite ::= c_stmts_opt jmp_abs new_block ''' - + def p_misc(self, args): + ''' + conditional ::= expr jmp_false expr jf_cf_pop expr + ''' class Python26ParserSingle(Python2Parser, PythonParserSingle): pass diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 1e9ea030..a4c06ae2 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1045,6 +1045,12 @@ class SourceWalker(GenericASTTraversal, object): # FIXME: clean this up if self.version > 3.0 and node == 'dictcomp': cn = node[1] + elif self.version < 2.7 and node == 'genexpr': + if node[0] == 'LOAD_GENEXPR': + cn = node[0] + elif node[0] == 'load_closure': + cn = node[1] + elif self.version > 3.0 and node == 'genexpr': if node[0] == 'load_genexpr': load_genexpr = node[0]