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 accurate 3.6 "ifsmt" and "ifelsesmt"
This commit is contained in:
Binary file not shown.
@@ -8,3 +8,33 @@ def init(modules=None):
|
||||
|
||||
assert init() == set()
|
||||
assert init([1, 2, 3]) == set([1, 2, 3])
|
||||
|
||||
# From 3.6 sre_parse
|
||||
# Bug was in handling multple COME_FROMS from nested if's
|
||||
def _escape(a, b, c, d, e):
|
||||
if a:
|
||||
if b:
|
||||
if c:
|
||||
if d:
|
||||
raise
|
||||
return
|
||||
if e:
|
||||
if d:
|
||||
raise
|
||||
return
|
||||
raise
|
||||
|
||||
assert _escape(False, True, True, True, True) is None
|
||||
assert _escape(True, True, True, False, True) is None
|
||||
assert _escape(True, True, False, False, True) is None
|
||||
|
||||
for args in (
|
||||
(True, True, True, False, True),
|
||||
(True, False, True, True, True),
|
||||
(True, False, True, True, False),
|
||||
):
|
||||
try:
|
||||
_escape(*args)
|
||||
assert False, args
|
||||
except:
|
||||
pass
|
||||
|
@@ -149,7 +149,7 @@ class Python3Parser(PythonParser):
|
||||
testtrue ::= expr jmp_true
|
||||
|
||||
_ifstmts_jump ::= return_if_stmts
|
||||
_ifstmts_jump ::= c_stmts_opt COME_FROM
|
||||
_ifstmts_jump ::= c_stmts_opt come_froms
|
||||
|
||||
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE
|
||||
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK
|
||||
@@ -1516,6 +1516,10 @@ class Python3Parser(PythonParser):
|
||||
# from trepan.api import debug; debug()
|
||||
return condition_jump.attr < condition_jump2.off2int()
|
||||
return False
|
||||
elif rule == ("ifstmt", ("testexpr", "\\e___ifstmts_jump")):
|
||||
# I am not sure what to check.
|
||||
# Probably needs fixing elsewhere
|
||||
return True
|
||||
elif lhs == "ifelsestmt" and rule[1][2] == "jump_forward_else":
|
||||
last = min(last, len(tokens) - 1)
|
||||
if tokens[last].off2int() == -1:
|
||||
|
@@ -21,7 +21,6 @@ from uncompyle6.parser import PythonParserSingle, nop_func
|
||||
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||
from uncompyle6.parsers.parse35 import Python35Parser
|
||||
from uncompyle6.scanners.tok import Token
|
||||
from uncompyle6.parsers.reducecheck import ifelsestmt, iflaststmt, and_check
|
||||
|
||||
class Python36Parser(Python35Parser):
|
||||
|
||||
@@ -116,6 +115,7 @@ class Python36Parser(Python35Parser):
|
||||
jb_cfs ::= JUMP_BACK come_froms
|
||||
ifelsestmtl ::= testexpr c_stmts_opt jb_cfs else_suitel
|
||||
ifelsestmtl ::= testexpr c_stmts_opt cf_jf_else else_suitel
|
||||
ifelsestmt ::= testexpr c_stmts_opt cf_jf_else else_suite _come_froms
|
||||
|
||||
# In 3.6+, A sequence of statements ending in a RETURN can cause
|
||||
# JUMP_FORWARD END_FINALLY to be omitted from try middle
|
||||
|
Reference in New Issue
Block a user