You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
Add jump range check for 2.7 assert_expr_and
This commit is contained in:
@@ -638,6 +638,7 @@ class Python2Parser(PythonParser):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
self.check_reduce["raise_stmt1"] = "tokens"
|
self.check_reduce["raise_stmt1"] = "tokens"
|
||||||
|
self.check_reduce["assert_expr_and"] = "AST"
|
||||||
self.check_reduce["aug_assign2"] = "AST"
|
self.check_reduce["aug_assign2"] = "AST"
|
||||||
self.check_reduce["or"] = "AST"
|
self.check_reduce["or"] = "AST"
|
||||||
# self.check_reduce['_stmts'] = 'AST'
|
# self.check_reduce['_stmts'] = 'AST'
|
||||||
@@ -660,6 +661,10 @@ class Python2Parser(PythonParser):
|
|||||||
and ast[0][0] in ("and", "or")
|
and ast[0][0] in ("and", "or")
|
||||||
):
|
):
|
||||||
return True
|
return True
|
||||||
|
elif lhs == "assert_expr_and":
|
||||||
|
jmp_false = ast[1]
|
||||||
|
jump_target = jmp_false[0].attr
|
||||||
|
return jump_target > tokens[last].offset
|
||||||
elif lhs in ("raise_stmt1",):
|
elif lhs in ("raise_stmt1",):
|
||||||
# We will assume 'LOAD_ASSERT' will be handled by an assert grammar rule
|
# We will assume 'LOAD_ASSERT' will be handled by an assert grammar rule
|
||||||
return tokens[first] == "LOAD_ASSERT" and (last >= len(tokens))
|
return tokens[first] == "LOAD_ASSERT" and (last >= len(tokens))
|
||||||
|
Reference in New Issue
Block a user