Fix 3.5, 3.6 while true if/break bug

This commit is contained in:
rocky
2017-01-08 15:54:49 -05:00
parent 66518baed0
commit 3f40c16587
6 changed files with 18 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,7 @@
# Python 3.5 and 3.6 break inside a
# while True and if / break
def display_date(loop):
while True:
if loop.time():
break
x = 5

View File

@@ -109,6 +109,8 @@ class Python35Parser(Python34Parser):
# differently than 3.3, 3.4
yield_from ::= expr GET_YIELD_FROM_ITER LOAD_CONST YIELD_FROM
_ifstmts_jump ::= c_stmts_opt COME_FROM
"""
def add_custom_rules(self, tokens, customize):

View File

@@ -226,7 +226,7 @@ class Scanner(object):
for given opcode <op>.
"""
if op < self.opc.HAVE_ARGUMENT:
return 1
return 2 if self.version >= 3.6 else 1
else:
return 2 if self.version >= 3.6 else 3

View File

@@ -851,7 +851,8 @@ class Scanner3(Scanner):
'start': start,
'end': pre_rtarget})
self.not_continue.add(pre_rtarget)
elif code[pre_rtarget] == self.opc.RETURN_VALUE:
elif code[pre_rtarget] in (self.opc.RETURN_VALUE,
self.opc.BREAK_LOOP):
self.structs.append({'type': 'if-then',
'start': start,
'end': rtarget})
@@ -881,7 +882,12 @@ class Scanner3(Scanner):
return
pass
pass
if code[pre_rtarget] == self.opc.RETURN_VALUE:
self.return_end_ifs.add(pre_rtarget)
else:
self.fixed_jumps[offset] = rtarget
self.not_continue.add(pre_rtarget)
elif op == self.opc.SETUP_EXCEPT:
target = self.get_target(offset)