From bc7d7ddf12973b5c23caad3abe2c9a2ce7982d75 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 14 Dec 2019 17:23:37 -0500 Subject: [PATCH] Narrow what's excepted for iflastsmtl... Disallow "if" jump to jump inside body of "then". --- test/stdlib/runtests.sh | 4 +--- uncompyle6/parsers/parse27.py | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/stdlib/runtests.sh b/test/stdlib/runtests.sh index 45e74859..dd2c11b0 100755 --- a/test/stdlib/runtests.sh +++ b/test/stdlib/runtests.sh @@ -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 diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index a83eb278..9e947f6c 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -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