diff --git a/test/bytecode_3.8/01_while_if_then.pyc b/test/bytecode_3.8/01_while_if_then.pyc new file mode 100644 index 00000000..59917a81 Binary files /dev/null and b/test/bytecode_3.8/01_while_if_then.pyc differ diff --git a/uncompyle6/parsers/parse38.py b/uncompyle6/parsers/parse38.py index c750ffb0..969706db 100644 --- a/uncompyle6/parsers/parse38.py +++ b/uncompyle6/parsers/parse38.py @@ -20,7 +20,6 @@ from __future__ import print_function from uncompyle6.parser import PythonParserSingle from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG from uncompyle6.parsers.parse37 import Python37Parser -from uncompyle6.scanners.tok import Token class Python38Parser(Python37Parser): @@ -35,6 +34,7 @@ class Python38Parser(Python37Parser): stmt ::= try_except_ret38 stmt ::= try_except38 stmt ::= whilestmt38 + stmt ::= whileTruestmt38 # FIXME this should be restricted to being inside a try block stmt ::= except_ret38 @@ -67,12 +67,11 @@ class Python38Parser(Python37Parser): whilestmt38 ::= testexpr l_stmts JUMP_BACK # while1elsestmt ::= l_stmts JUMP_BACK - whileelsestmt ::= testexpr l_stmts JUMP_BACK POP_BLOCK whileTruestmt ::= l_stmts JUMP_BACK POP_BLOCK while1stmt ::= l_stmts COME_FROM_LOOP while1stmt ::= l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP - whileTruestmt ::= l_stmts JUMP_BACK NOP - whileTruestmt ::= l_stmts JUMP_BACK POP_BLOCK NOP + whileTruestmt38 ::= l_stmts JUMP_BACK + for_block ::= l_stmts_opt _come_from_loops JUMP_BACK except_cond1 ::= DUP_TOP expr COMPARE_OP jmp_false diff --git a/uncompyle6/semantics/customize3.py b/uncompyle6/semantics/customize3.py index 0e785a9e..7763bce4 100644 --- a/uncompyle6/semantics/customize3.py +++ b/uncompyle6/semantics/customize3.py @@ -982,6 +982,8 @@ def customize_for_version3(self, version): 'whilestmt38': ( '%|while %c:\n%+%c%-\n\n', (0, 'testexpr'), (1, 'l_stmts') ), + 'whileTruestmt38': ( '%|while True:\n%+%c%-\n\n', + (0, 'l_stmts') ), 'tryfinally38': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', (3, 'returns'), 6 ),