From 7f798541f06332eb9ebf62d04f808038259b040a Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 16 Jun 2022 15:42:51 -0400 Subject: [PATCH] Python 3.8 while and whileTrue loops --- test/bytecode_3.7/00_while_true_pass.pyc | Bin 0 -> 149 bytes test/bytecode_3.8/00_while_true_pass.pyc | Bin 0 -> 147 bytes test/simple_source/bug38/00_while_true_pass.py | 6 ++++++ uncompyle6/parsers/parse38.py | 1 + uncompyle6/semantics/customize38.py | 5 ++++- 5 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/bytecode_3.7/00_while_true_pass.pyc create mode 100644 test/bytecode_3.8/00_while_true_pass.pyc create mode 100644 test/simple_source/bug38/00_while_true_pass.py 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 0000000000000000000000000000000000000000..d03bde5bd7e544d484c955b9913f3971bd1fba81 GIT binary patch literal 149 zcmZ?b<>g`kf=jKdljZ^G#~=<2FajA4KwQiRBvKiQxGGo**}@r87=jrz8T~XFZ*j!O z=OyN*#>cN@C}IMt0TaJ8i!*Zza#G`q^Gl18Q}vTd(~T|k4GiMTGctjqB}JvF@db&+ b#d-ymw>WHa^HWN5Qtenk)_@2WMkYo87Ca+Q literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..2bc34752e51dae442e5d4f948aaf4a9e1f019f8c GIT binary patch literal 147 zcmWIL<>g`kf=jKdljZ^G#~=ER~^%t&k;!A(%mv(NB}{7Ds%1USe)) zeEdp=A|{|bnE0hxoS9pYlNw)~Us{x$s-IMvZfv1%U=UxPkqHznDJo5kFGwsd)+?yI V#bJ}1pHiBWYR3Yy0%QaW699cFB7pz^ literal 0 HcmV?d00001 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"),