You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Add 2.x if vs if/else reduction rule check
This commit is contained in:
@@ -32,11 +32,11 @@ typeset -A SKIP_TESTS
|
||||
case $PYVERSION in
|
||||
2.4)
|
||||
SKIP_TESTS=(
|
||||
[test_decimal.py]=1 #
|
||||
[test_dis.py]=1 # We change line numbers - duh!
|
||||
[test_grp.py]=1 # Long test - might work Control flow?
|
||||
[test_pep247.py]=1 # Long test - might work? Control flow?
|
||||
[test_pwd.py]=1 # Long test - might work? Control flow?
|
||||
[test_pyclbr.py]=1 # Investigate
|
||||
[test_socketserver.py]=1 # -- test takes too long to run: 40 seconds
|
||||
[test_threading.py]=1 # test takes too long to run: 11 seconds
|
||||
[test_thread.py]=1 # test takes too long to run: 36 seconds
|
||||
|
@@ -643,6 +643,7 @@ class Python2Parser(PythonParser):
|
||||
self.check_reduce["tryelsestmtl"] = "AST"
|
||||
self.check_reduce["aug_assign2"] = "AST"
|
||||
self.check_reduce["or"] = "AST"
|
||||
self.check_reduce["ifstmt"] = "tokens"
|
||||
# self.check_reduce['_stmts'] = 'AST'
|
||||
|
||||
# Dead code testing...
|
||||
@@ -667,6 +668,14 @@ class Python2Parser(PythonParser):
|
||||
jmp_false = ast[1]
|
||||
jump_target = jmp_false[0].attr
|
||||
return jump_target > tokens[last].off2int()
|
||||
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
|
||||
pass
|
||||
elif lhs in ("raise_stmt1",):
|
||||
# We will assume 'LOAD_ASSERT' will be handled by an assert grammar rule
|
||||
return tokens[first] == "LOAD_ASSERT" and (last >= len(tokens))
|
||||
|
Reference in New Issue
Block a user