You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Bug in 3.0 rule in "jump_absolute_else" ...
and disallowing "else" to the wrong place.
This commit is contained in:
Binary file not shown.
@@ -35,3 +35,16 @@ def __instancecheck__(subtype, subclass, cls):
|
|||||||
if subtype:
|
if subtype:
|
||||||
if (cls and subclass):
|
if (cls and subclass):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
# Adapted from 3.0.1 abc.py
|
||||||
|
# Bug was rule in "jump_absolute_else" and disasllowing
|
||||||
|
# "else" to the wrong place.
|
||||||
|
|
||||||
|
def _strptime(locale_time, found_zone, time):
|
||||||
|
for tz_values in locale_time:
|
||||||
|
if found_zone:
|
||||||
|
if (time and found_zone):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
@@ -43,7 +43,11 @@ class Python30Parser(Python31Parser):
|
|||||||
|
|
||||||
else_suitel ::= l_stmts COME_FROM_LOOP JUMP_BACK
|
else_suitel ::= l_stmts COME_FROM_LOOP JUMP_BACK
|
||||||
|
|
||||||
|
jump_absolute_else ::= COME_FROM JUMP_ABSOLUTE COME_FROM POP_TOP
|
||||||
|
|
||||||
|
ifelsestmtc ::= testexpr c_stmts_opt jump_absolute_else else_suitec
|
||||||
ifelsestmtl ::= testexpr c_stmts_opt jb_pop_top else_suitel
|
ifelsestmtl ::= testexpr c_stmts_opt jb_pop_top else_suitel
|
||||||
|
|
||||||
iflaststmtl ::= testexpr c_stmts_opt jb_pop_top
|
iflaststmtl ::= testexpr c_stmts_opt jb_pop_top
|
||||||
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE COME_FROM POP_TOP
|
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE COME_FROM POP_TOP
|
||||||
|
|
||||||
@@ -187,7 +191,7 @@ class Python30Parser(Python31Parser):
|
|||||||
|
|
||||||
self.check_reduce["iflaststmtl"] = "AST"
|
self.check_reduce["iflaststmtl"] = "AST"
|
||||||
self.check_reduce['ifstmt'] = "AST"
|
self.check_reduce['ifstmt'] = "AST"
|
||||||
# self.check_reduce["ifelsestmt"] = "AST"
|
self.check_reduce["ifelsestmtc"] = "AST"
|
||||||
return
|
return
|
||||||
|
|
||||||
def reduce_is_invalid(self, rule, ast, tokens, first, last):
|
def reduce_is_invalid(self, rule, ast, tokens, first, last):
|
||||||
@@ -197,12 +201,17 @@ class Python30Parser(Python31Parser):
|
|||||||
if invalid:
|
if invalid:
|
||||||
return invalid
|
return invalid
|
||||||
if (
|
if (
|
||||||
rule[0] in ("iflaststmtl", "ifstmt") and ast[0] == "testexpr"
|
rule[0] in ("iflaststmtl", "ifstmt", "ifelsestmtc") and ast[0] == "testexpr"
|
||||||
):
|
):
|
||||||
testexpr = ast[0]
|
testexpr = ast[0]
|
||||||
if testexpr[0] == "testfalse":
|
if testexpr[0] == "testfalse":
|
||||||
testfalse = testexpr[0]
|
testfalse = testexpr[0]
|
||||||
if testfalse[1] == "jmp_false":
|
if rule[0] == "ifelsestmtc" and ast[2] == "jump_absolute_else":
|
||||||
|
jump_absolute_else = ast[2]
|
||||||
|
come_from = jump_absolute_else[2]
|
||||||
|
return come_from == "COME_FROM" and come_from.attr < tokens[first].offset
|
||||||
|
pass
|
||||||
|
elif testfalse[1] == "jmp_false":
|
||||||
jmp_false = testfalse[1]
|
jmp_false = testfalse[1]
|
||||||
if last == len(tokens):
|
if last == len(tokens):
|
||||||
last -= 1
|
last -= 1
|
||||||
|
Reference in New Issue
Block a user