diff --git a/test/bytecode_2.6/07_return_end_if.pyc b/test/bytecode_2.6/07_return_end_if.pyc new file mode 100644 index 00000000..65c2dbe1 Binary files /dev/null and b/test/bytecode_2.6/07_return_end_if.pyc differ diff --git a/test/simple_source/looping/07_return_end_if.py b/test/simple_source/looping/07_return_end_if.py new file mode 100644 index 00000000..a64bca96 --- /dev/null +++ b/test/simple_source/looping/07_return_end_if.py @@ -0,0 +1,10 @@ +# 2.6.9 asynchat.py +# 2.6 added: +# return_stmt ::= ret_expr RETURN_END_IF come_from_pop +def initiate_send(self): + while self: + if self: + x = 'a' + else: + del self.producer_fifo[0] + return diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index bae4ec5e..fea1afa8 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -299,6 +299,8 @@ class PythonParser(GenericASTBuilder): while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM + + # This is Python 2.7+; segregate while1stmt ::= SETUP_LOOP return_stmts COME_FROM while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 6eff7053..4fc6af99 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -123,11 +123,13 @@ class Python26Parser(Python2Parser): whilestmt ::= SETUP_LOOP testexpr l_stmts_opt jb_cf_pop POP_BLOCK COME_FROM + while1stmt ::= SETUP_LOOP return_stmts POP_BLOCK COME_FROM + + return_stmt ::= ret_expr RETURN_END_IF come_from_pop return_if_stmt ::= ret_expr RETURN_END_IF come_from_pop iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK come_from_pop iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_from_pop - """ def p_comp26(self, args):