From e3579463ab04f046b11e1fa8687883233a2d4f09 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 13 Jul 2024 11:54:22 -0400 Subject: [PATCH] Loosen what is allowed in whilestmt38... Fixes #498 --- test/bytecode_3.8/03_while_bug.pyc | Bin 0 -> 205 bytes test/simple_source/bug38/03_while_bug.py | 9 +++++++++ uncompyle6/semantics/customize38.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/bytecode_3.8/03_while_bug.pyc create mode 100644 test/simple_source/bug38/03_while_bug.py diff --git a/test/bytecode_3.8/03_while_bug.pyc b/test/bytecode_3.8/03_while_bug.pyc new file mode 100644 index 0000000000000000000000000000000000000000..20a2d6d1c8e3354129dba164ada2da3473e6afb4 GIT binary patch literal 205 zcmWIL<>g`kf`^MIr5yy)k3k${zzpO#0CBMqkVs)jVa#EO0@6{8sf;O1*-S-xsZ6O1 z3m6tMG&3?XK*e}K@`XGpjKK_=%rAlZ82nx`0!dBgTP!7+xv94pi*B(N6lLa>tYj!+ z14@92U&_Uqxdl0?@x}S2Mail9Nu}w=7WxLp@#PtrKv5u9ub}c4hfQvNN@-529mrwD PAh&Zcu`qHl@&GXaehV#| literal 0 HcmV?d00001 diff --git a/test/simple_source/bug38/03_while_bug.py b/test/simple_source/bug38/03_while_bug.py new file mode 100644 index 00000000..4ed198b6 --- /dev/null +++ b/test/simple_source/bug38/03_while_bug.py @@ -0,0 +1,9 @@ +# See https://github.com/rocky/python-uncompyle6/issues/498 +# Bug was in not allowing _stmts in whilestmt38 +import time + +r = 0 +while r == 1: + print(time.time()) + if r == 1: + r = 0 diff --git a/uncompyle6/semantics/customize38.py b/uncompyle6/semantics/customize38.py index 67023299..df08c36f 100644 --- a/uncompyle6/semantics/customize38.py +++ b/uncompyle6/semantics/customize38.py @@ -144,7 +144,7 @@ def customize_for_version38(self, version): "whilestmt38": ( "%|while %c:\n%+%c%-\n\n", (1, ("bool_op", "testexpr", "testexprc")), - (2, ("l_stmts", "l_stmts_opt", "pass")), + (2, ("_stmts", "l_stmts", "l_stmts_opt", "pass")), ), "whileTruestmt38": ( "%|while True:\n%+%c%-\n\n",