From 14468fe8c9f50bb12d003f8d28d84157c34b59d2 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 6 Jan 2020 23:34:18 -0500 Subject: [PATCH] Go over 2.5 for reduction rules and tests --- test/stdlib/runtests.sh | 19 ++++++++++++++----- uncompyle6/parsers/parse2.py | 17 +++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/test/stdlib/runtests.sh b/test/stdlib/runtests.sh index 318d97e6..35ef669b 100755 --- a/test/stdlib/runtests.sh +++ b/test/stdlib/runtests.sh @@ -34,7 +34,7 @@ case $PYVERSION in SKIP_TESTS=( [test_decimal.py]=1 # [test_dis.py]=1 # We change line numbers - duh! - [test_generators.py]=1 # Investigate - botched if/elif control flow badly + [test_generators.py]=1 # Investigate [test_grammar.py]=1 # Too many stmts. Handle large stmts [test_grp.py]=1 # Long test - might work Control flow? [test_pep247.py]=1 # Long test - might work? Control flow? @@ -48,37 +48,46 @@ case $PYVERSION in ;; 2.5) SKIP_TESTS=( + [test_coercion.py]=1 + [test_decimal.py]=1 [test_dis.py]=1 # We change line numbers - duh! + [test_generators.py]=1 # Investigate [test_grammar.py]=1 # Too many stmts. Handle large stmts [test_grp.py]=1 # Long test - might work Control flow? [test_pdb.py]=1 # Line-number specific - [test_pep247.py]=1 # "assert xxx or .." not detected properly in check_hash_module() [test_pep352.py]=1 # Investigate [test_pwd.py]=1 # Long test - might work? Control flow? [test_pyclbr.py]=1 # Investigate [test_queue.py]=1 # Control flow? - [test_re.py]=1 # Possibly try confused with try-else again + [test_socketserver.py]=1 # Too long to run - 42 seconds [test_struct.py]=1 # "if and" confused for if .. assert and - [test_sys.py]=1 # try confused with try-else again; in test_current_frames() - [test_tarfile.py]=1 # try confused with try-else again; top-level import [test_threading.py]=1 # test takes too long to run: 11 seconds [test_thread.py]=1 # test takes too long to run: 36 seconds [test_trace.py]=1 # Line numbers are expected to be different + [test_urllib2net.py]=1 # is interactive? [test_zipfile64.py]=1 # Runs ok but takes 204 seconds ) ;; 2.6) SKIP_TESTS=( [test_aepack.py]=1 # Fails on its own + [test_cmath.py]=1 # Investigate: probably fixable like in later versions + [test_coercion.py]=1 [test_codeccallbacks.py]=1 # Fails on its own [test_compile.py]=1 # Intermittent - sometimes works and sometimes doesn't + [test_dis.py]=1 # We change line numbers - duh! [test_exceptions.py]=1 + [test_float.py]=1 # Investigate: probably fixable like in later versions + [test_generators.py]=1 # Investigate [test_grp.py]=1 # Long test - might work Control flow? + [test_itertools.py]=1 # complex numbers. Fix as we do in later versions + [test_math.py]=1 # Probably fixable like later versions [test_pep352.py]=1 # Investigate [test_pprint.py]=1 [test_pyclbr.py]=1 # Investigate [test_pwd.py]=1 # Long test - might work? Control flow? [test_trace.py]=1 # Line numbers are expected to be different + [test_types.py]=1 # Probably fixable like later versions [test_urllib2net.py]=1 # Fails on its own. May need interactive input [test_zipfile64.py]=1 # Skip Long test [test_zlib.py]=1 # Takes too long to run (more than 3 minutes 39 seconds) diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index d0c67674..cdc3d757 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -707,12 +707,14 @@ class Python2Parser(PythonParser): pass pass elif rule == ("ifstmt", ("testexpr", "_ifstmts_jump")): - for i in range(last-1, last-4, -1): - t = tokens[i] - if t == "JUMP_FORWARD": - return t.attr > tokens[min(last, len(tokens)-1)].off2int() - elif t not in ("POP_TOP", "COME_FROM"): - break + # FIXME: move this into 2.7-specific code? + if self.version == 2.7: + for i in range(last-1, last-4, -1): + t = tokens[i] + if t == "JUMP_FORWARD": + return t.attr > tokens[min(last, len(tokens)-1)].off2int() + elif t not in ("POP_TOP", "COME_FROM"): + break pass elif lhs in ("raise_stmt1",): # We will assume 'LOAD_ASSERT' will be handled by an assert grammar rule @@ -736,9 +738,12 @@ class Python2Parser(PythonParser): # ti will be invalid here. if come_from == "COME_FROM": first_come_from = except_handler[-1] + elif come_from == "END_FINALLY": + return False else: assert come_from == "come_froms" first_come_from = come_from[0] + leading_jump = except_handler[0] # We really don't care that this is a jump per-se. But