diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 155d1983..35c79813 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -70,6 +70,7 @@ class Python26Parser(Python2Parser): come_from_pop ::= COME_FROM POP_TOP _ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM + _ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM come_from_pop """ def p_stmt26(self, args): @@ -92,7 +93,6 @@ class Python26Parser(Python2Parser): POP_BLOCK _come_from return_if_stmt ::= ret_expr RETURN_END_IF come_from_pop - """ def p_comp26(self, args): @@ -106,6 +106,10 @@ class Python26Parser(Python2Parser): designator list_iter JUMP_BACK del_stmt lc_body ::= LOAD_NAME expr LIST_APPEND lc_body ::= LOAD_FAST expr LIST_APPEND + + # Make sure we keep indices the same as 2.7 + setup_loop_lf ::= SETUP_LOOP LOAD_FAST + genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK POP_BLOCK COME_FROM ''' def p_ret26(self, args): diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index d693c594..ec52d41d 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1067,6 +1067,7 @@ class SourceWalker(GenericASTTraversal, object): n = ast[iter_index] assert n == 'comp_iter' + # find innermost node while n == 'comp_iter': # list_iter n = n[0] # recurse one step