Adjust 3.x while1else reduction check

This commit is contained in:
rocky
2018-03-20 11:33:10 -04:00
parent 0e64111195
commit 90ac8a463d
4 changed files with 15 additions and 2 deletions

View File

@@ -25,3 +25,13 @@ def readline2(self):
continue
return line + self[0]
# From 3.4.4 connection.py
def PipeClient(address):
while 1:
try:
address += 1
except OSError as e:
raise e
else:
raise

View File

@@ -1090,7 +1090,7 @@ class Python3Parser(PythonParser):
if tokens[last] in ('JUMP_BACK', 'CONTINUE'):
# These indicate inside a loop, but token[last]
# should not be in a loop.
# FIXME: Not quite righte: refine by using target
# FIXME: Not quite right: refine by using target
return True
# if SETUP_LOOP target spans the else part, then this is
@@ -1100,7 +1100,7 @@ class Python3Parser(PythonParser):
last += 1
if last == n:
return False
return tokens[first].attr >= tokens[last].offset
return tokens[first].attr > tokens[last].offset
elif lhs == 'while1stmt':
# If there is a fall through to the COME_FROM_LOOP. then this is

View File

@@ -42,6 +42,9 @@ class Python34Parser(Python33Parser):
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
else_suitel COME_FROM
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK else_suitel
COME_FROM_LOOP
# Python 3.4+ optimizes the trailing two JUMPS away
# Is this 3.4 only?