Adapt decompyle3's 3.8 try/return grammar rules

This commit is contained in:
rocky
2020-05-17 10:18:10 -04:00
parent d343384db7
commit 4365022f40
7 changed files with 109 additions and 31 deletions

View File

@@ -2053,10 +2053,17 @@ class SourceWalker(GenericASTTraversal, object):
elif typ == "c":
index = entry[arg]
if isinstance(index, tuple):
assert node[index[0]] == index[1], (
"at %s[%d], expected '%s' node; got '%s'"
% (node.kind, arg, index[1], node[index[0]].kind)
)
if isinstance(index[1], str):
assert node[index[0]] == index[1], (
"at %s[%d], expected '%s' node; got '%s'"
% (node.kind, arg, index[1], node[index[0]].kind)
)
else:
assert node[index[0]] in index[1], (
"at %s[%d], expected to be in '%s' node; got '%s'"
% (node.kind, arg, index[1], node[index[0]].kind)
)
index = index[0]
assert isinstance(
index, int
@@ -2065,6 +2072,16 @@ class SourceWalker(GenericASTTraversal, object):
arg,
type(index),
)
try:
node[index]
except IndexError:
raise RuntimeError(
"""
Expanding '%' in template '%s[%s]':
%s is invalid; has only %d entries
""" % (node,kind, enty, arg, index, len(node))
)
self.preorder(node[index])
arg += 1