diff --git a/test/bytecode_3.2/09_if_whiletrue_bug.pyc b/test/bytecode_3.2/09_if_whiletrue_bug.pyc new file mode 100644 index 00000000..ff0bab4c Binary files /dev/null and b/test/bytecode_3.2/09_if_whiletrue_bug.pyc differ diff --git a/test/simple_source/looping/09_if_whiletrue_bug.py b/test/simple_source/looping/09_if_whiletrue_bug.py new file mode 100644 index 00000000..7a7b68e3 --- /dev/null +++ b/test/simple_source/looping/09_if_whiletrue_bug.py @@ -0,0 +1,19 @@ +# Test Bug in handling whileTrue jumping around an else + +# Python 3.2 has +# whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK _come_from +# where Python 3.5 has +# whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK _come_from + +import sys + +rv = 0 +if sys.argv == ['-']: + while True: + filename = sys.argv[0] + try: + compile(filename, doraise=True) + except IOError: + rv = 1 +else: + rv = 1 diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 28c8b2dc..a502a79d 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -333,8 +333,13 @@ class Python3Parser(PythonParser): def p_stmt3(self, args): """ stmt ::= whileTruestmt - whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK _come_from ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite _come_from + + # Python 3.5 may have POP_BLOCK + whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK _come_from + + # Python < 3.5 no POP BLOCK + whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK \e__come_from """ def p_genexpr3(self, args):