Skirt around control-flow problems...

Tag some of the weaknesses if we can't address them now
This commit is contained in:
rocky
2017-12-07 08:55:45 -05:00
parent 41db5b8848
commit b6413b6e6e
5 changed files with 15 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
# while True and if / break
def display_date(loop):
while True:
if loop.time():
if loop:
break
x = 5

View File

@@ -26,6 +26,14 @@ class Python35Parser(Python34Parser):
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK
POP_BLOCK else_suite COME_FROM_LOOP
# The following rule is for Python 3.5+ where we can have stuff like
# while ..
# if
# ...
# the end of the if will jump back to the loop and there will be a COME_FROM
# after the jump
l_stmts ::= lastl_stmt COME_FROM l_stmts
# Python 3.5+ Await statement
expr ::= await_expr
await_expr ::= expr GET_AWAITABLE LOAD_CONST YIELD_FROM

View File

@@ -208,6 +208,9 @@ class Scanner(object):
Return a list with indexes to them or [] if none found.
"""
# FIXME: this is broken on 3.6+. Revise to use instructions self.insts
code = self.code
assert(start >= 0 and end <= len(code))

View File

@@ -363,7 +363,7 @@ class Scanner3(Scanner):
# FIXME: 0 isn't always correct
target = self.get_target(inst.offset)
if target <= inst.offset:
next_opname = self.opname[self.code[inst.offset+3]]
next_opname = self.insts[i+1].opname
if (inst.offset in self.stmts and
(self.version != 3.0 or (hasattr(inst, 'linestart'))) and
(next_opname not in ('END_FINALLY', 'POP_BLOCK',
@@ -948,12 +948,12 @@ class Scanner3(Scanner):
self.not_continue.add(pre_rtarget)
else:
# For now, we'll only tag forward jump.
if self.version >= 3.6:
if self.version >= 3.5:
if target > offset:
self.fixed_jumps[offset] = target
pass
else:
# FIXME: This is probably a bug in < 3.6 and we should
# FIXME: This is probably a bug in < 3.5 and we should
# instead use the above code. But until we smoke things
# out we'll stick with it.
if rtarget > offset: