Python 3 "while True" bug

This commit is contained in:
rocky 2016-05-09 14:44:01 -04:00
parent 378cca27da
commit d823dfb5d3
4 changed files with 17 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,9 @@
if args == ['-']:
while True:
try:
compile(filename, doraise=True)
except RuntimeError:
rv = 1
else:
rv = 1
print(rv)

View File

@ -330,6 +330,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
"""
def p_genexpr3(self, args):
'''
load_genexpr ::= LOAD_GENEXPR

View File

@ -302,6 +302,7 @@ TABLE_DIRECT = {
'ifelsestmtr': ( '%|if %c:\n%+%c%-%|else:\n%+%c%-', 0, 1, 2 ),
'elifelsestmtr': ( '%|elif %c:\n%+%c%-%|else:\n%+%c%-\n\n', 0, 1, 2 ),
'whileTruestmt': ( '%|while True:\n%+%c%-\n\n', 1 ),
'whilestmt': ( '%|while %c:\n%+%c%-\n\n', 1, 2 ),
'while1stmt': ( '%|while 1:\n%+%c%-\n\n', 1 ),
'while1elsestmt': ( '%|while 1:\n%+%c%-%|else:\n%+%c%-\n\n', 1, 3 ),