You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
More reduction checks...
Those in reduce check as well as those listed in parse{2,3}. 3.6 iflastsmtl needs ifstmt checking.
This commit is contained in:
@@ -671,8 +671,8 @@ class Python2Parser(PythonParser):
|
||||
|
||||
fn = self.reduce_check_table.get(lhs, None)
|
||||
if fn:
|
||||
return fn(self, lhs, n, rule, ast, tokens, first, last)
|
||||
|
||||
if fn(self, lhs, n, rule, ast, tokens, first, last):
|
||||
return True
|
||||
if rule == ("and", ("expr", "jmp_false", "expr", "\\e_come_from_opt")):
|
||||
# If the instruction after the instructions forming the "and" is an "YIELD_VALUE"
|
||||
# then this is probably an "if" inside a comprehension.
|
||||
|
@@ -1573,15 +1573,19 @@ class Python3Parser(PythonParser):
|
||||
last = min(last, n-1)
|
||||
fn = self.reduce_check_table.get(lhs, None)
|
||||
if fn:
|
||||
return fn(self, lhs, n, rule, ast, tokens, first, last)
|
||||
if fn(self, lhs, n, rule, ast, tokens, first, last):
|
||||
return True
|
||||
pass
|
||||
# FIXME: put more in reduce_check_table
|
||||
elif lhs in ("aug_assign1", "aug_assign2") and ast[0][0] == "and":
|
||||
if lhs in ("aug_assign1", "aug_assign2") and ast[0][0] == "and":
|
||||
return True
|
||||
elif lhs == "annotate_tuple":
|
||||
return not isinstance(tokens[first].attr, tuple)
|
||||
elif lhs == "kwarg":
|
||||
arg = tokens[first].attr
|
||||
return not (isinstance(arg, str) or isinstance(arg, unicode))
|
||||
elif lhs in ("iflaststmt", "iflaststmtl") and self.version == 3.6:
|
||||
return ifstmt(self, lhs, n, rule, ast, tokens, first, last)
|
||||
elif rule == ("ifstmt", ("testexpr", "_ifstmts_jump")):
|
||||
# FIXME: go over what's up with 3.0. Evetually I'd like to remove RETURN_END_IF
|
||||
if self.version <= 3.0 or tokens[last] == "RETURN_END_IF":
|
||||
|
Reference in New Issue
Block a user