diff --git a/test/bytecode_3.4/04_while1_while1.pyc b/test/bytecode_3.4/04_while1_while1.pyc index dcfbc4e6..6ce08f29 100644 Binary files a/test/bytecode_3.4/04_while1_while1.pyc and b/test/bytecode_3.4/04_while1_while1.pyc differ diff --git a/test/simple_source/looping/04_while1_while1.py b/test/simple_source/looping/04_while1_while1.py index 849bf110..10c106c2 100644 --- a/test/simple_source/looping/04_while1_while1.py +++ b/test/simple_source/looping/04_while1_while1.py @@ -7,3 +7,22 @@ while 1: raise RuntimeError else: raise RuntimeError + +while 1: + if __file__: + if __name__: + raise RuntimeError + else: + # flags + while __name__: + group = 5 +while 1: + if __name__: + while 1: + if y: + break + raise RuntimeError + elif __file__: + x = 2 + else: + raise RuntimeError diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index f752d775..68d0e8d7 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -137,6 +137,7 @@ class Python3Parser(PythonParser): iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK + iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK COME_FROM_LOOP ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite COME_FROM @@ -145,6 +146,8 @@ class Python3Parser(PythonParser): ifelsestmtr ::= testexpr return_if_stmts return_stmts ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel + ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel JUMP_BACK COME_FROM_LOOP + ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel COME_FROM_LOOP # FIXME: this feels like a hack. Is it just 1 or two @@ -301,6 +304,12 @@ class Python3Parser(PythonParser): whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM_LOOP + + # The JUMP_ABSOLUTE below comes from escaping an "if" block which surrounds + # the while. This is messy + whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK + JUMP_ABSOLUTE COME_FROM_LOOP + whilestmt ::= SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM_LOOP @@ -314,21 +323,23 @@ class Python3Parser(PythonParser): whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM_LOOP + while1stmt ::= SETUP_LOOP l_stmts + # Python < 3.5 no POP BLOCK whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM_LOOP whileTruestmt ::= SETUP_LOOP return_stmts COME_FROM_LOOP - while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM_LOOP - # FIXME: investigate - can code really produce a NOP? - whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP - COME_FROM_LOOP - whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP - COME_FROM_LOOP - forstmt ::= SETUP_LOOP expr _for designator for_block POP_BLOCK NOP - COME_FROM_LOOP + whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP + COME_FROM_LOOP + whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP + COME_FROM_LOOP + whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP + COME_FROM_LOOP + forstmt ::= SETUP_LOOP expr _for designator for_block POP_BLOCK NOP + COME_FROM_LOOP """ def p_genexpr3(self, args):