diff --git a/test/bytecode_3.7/00_while_true_pass.pyc b/test/bytecode_3.7/00_while_true_pass.pyc new file mode 100644 index 00000000..d03bde5b Binary files /dev/null and b/test/bytecode_3.7/00_while_true_pass.pyc differ diff --git a/test/bytecode_3.8/00_while_true_pass.pyc b/test/bytecode_3.8/00_while_true_pass.pyc new file mode 100644 index 00000000..2bc34752 Binary files /dev/null and b/test/bytecode_3.8/00_while_true_pass.pyc differ diff --git a/test/simple_source/bug38/00_while_true_pass.py b/test/simple_source/bug38/00_while_true_pass.py new file mode 100644 index 00000000..cdc01f0d --- /dev/null +++ b/test/simple_source/bug38/00_while_true_pass.py @@ -0,0 +1,6 @@ +# The 3.8 bugs were in detecting +# 1) while True: pass +# 2) confusing the "if" ending in a loop jump with a "while" +if __name__: + while True: + pass diff --git a/uncompyle6/parsers/parse38.py b/uncompyle6/parsers/parse38.py index d38abced..2bead40b 100644 --- a/uncompyle6/parsers/parse38.py +++ b/uncompyle6/parsers/parse38.py @@ -142,6 +142,7 @@ class Python38Parser(Python37Parser): while1stmt ::= _come_froms l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP whileTruestmt38 ::= _come_froms l_stmts JUMP_BACK whileTruestmt38 ::= _come_froms l_stmts JUMP_BACK COME_FROM_EXCEPT_CLAUSE + whileTruestmt38 ::= _come_froms pass JUMP_BACK for_block ::= _come_froms l_stmts_opt _come_from_loops JUMP_BACK diff --git a/uncompyle6/semantics/customize38.py b/uncompyle6/semantics/customize38.py index 4638c35d..6c1a37a4 100644 --- a/uncompyle6/semantics/customize38.py +++ b/uncompyle6/semantics/customize38.py @@ -125,7 +125,10 @@ def customize_for_version38(self, version): (1, "testexpr"), (2, ("l_stmts", "pass")), ), - "whileTruestmt38": ("%|while True:\n%+%c%-\n\n", (1, "l_stmts", "pass"),), + "whileTruestmt38": ( + "%|while True:\n%+%c%-\n\n", + (1, ("l_stmts", "pass")), + ), "try_elsestmtl38": ( "%|try:\n%+%c%-%c%|else:\n%+%c%-", (1, "suite_stmts_opt"),