Narrow what's excepted for iflastsmtl...

Disallow "if" jump to jump inside body of "then".
This commit is contained in:
rocky
2019-12-14 17:23:37 -05:00
parent 41b6e91286
commit bc7d7ddf12
2 changed files with 6 additions and 8 deletions

View File

@@ -75,7 +75,7 @@ case $PYVERSION in
[test_codeccallbacks.py]=1 # Fails on its own
[test_compile.py]=1 # Intermittent - sometimes works and sometimes doesn't
[test_exceptions.py]=1
[test_generators.py]=1 # Investigate
[test_generators.py]=1 # Investigate. Recently fixed in 2.7? Fixed with reduction checks?
[test_grp.py]=1 # Long test - might work Control flow?
[test_pep352.py]=1 # Investigate
[test_pprint.py]=1
@@ -125,10 +125,8 @@ case $PYVERSION in
[test_doctest.py]=1 # Fails on its own
[test_exceptions.py]=1
[test_format.py]=1 # control flow. uncompyle2 does not have problems here
[test_generators.py]=1 # control flow. uncompyle2 has problem here too
[test_grammar.py]=1 # Too many stmts. Handle large stmts
[test_grp.py]=1 # test takes to long, works interactively though
[test_hashlib.py]=1 # Investigate
[test_io.py]=1 # Test takes too long to run
[test_ioctl.py]=1 # Test takes too long to run
[test_long.py]=1

View File

@@ -285,10 +285,10 @@ class Python27Parser(Python2Parser):
or jump_target == next_offset(ast[-1].op, ast[-1].opc, ast[-1].offset))
elif rule == ("iflaststmtl", ("testexpr", "c_stmts")):
testexpr = ast[0]
if testexpr[0] == "testfalse":
testfalse = testexpr[0]
if testfalse[1] == "jmp_false":
jmp_false = testfalse[1]
if testexpr[0] in ("testfalse", "testtrue"):
test = testexpr[0]
if len(test) > 1 and test[1].kind.startswith("jmp_"):
jmp_target = test[1][0].attr
if last == len(tokens):
last -= 1
while (isinstance(tokens[first].offset, str) and first < last):
@@ -297,7 +297,7 @@ class Python27Parser(Python2Parser):
return True
while (first < last and isinstance(tokens[last].offset, str)):
last -= 1
return tokens[first].offset < jmp_false[0].attr < tokens[last].offset
return tokens[first].off2int() < jmp_target < tokens[last].off2int()
pass
pass
pass