More 3.x "if" checking. Abbreviate stmts->sstmt

This commit is contained in:
rocky
2020-01-26 02:58:33 -05:00
parent 7721fbd276
commit 33918bd9d2
5 changed files with 17 additions and 9 deletions

View File

@@ -1103,7 +1103,10 @@ class SourceWalker(GenericASTTraversal, object):
code = Code(cn.attr, self.scanner, self.currentclass)
ast = self.build_ast(code._tokens, code._customize)
self.customize(code._customize)
ast = ast[0][0][0]
# Remove single reductions as in ("stmts", "sstmt"):
while len(ast) == 1:
ast = ast[0]
n = ast[iter_index]
assert n == "comp_iter", n
@@ -1368,7 +1371,11 @@ class SourceWalker(GenericASTTraversal, object):
code = Code(node[1].attr, self.scanner, self.currentclass)
ast = self.build_ast(code._tokens, code._customize)
self.customize(code._customize)
ast = ast[0][0][0]
# Remove single reductions as in ("stmts", "sstmt"):
while len(ast) == 1:
ast = ast[0]
store = ast[3]
collection = node[collection_index]
@@ -2208,6 +2215,7 @@ class SourceWalker(GenericASTTraversal, object):
pass
return
# This code is only for Python 1.x - 2.1 ish!
def get_tuple_parameter(self, ast, name):
"""
If the name of the formal parameter starts with dot,
@@ -2224,8 +2232,8 @@ class SourceWalker(GenericASTTraversal, object):
assert ast == "stmts"
for i in range(len(ast)):
# search for an assign-statement
assert ast[i][0] == "stmt"
node = ast[i][0][0]
assert ast[i] == "sstmt"
node = ast[i][0]
if node == "assign" and node[0] == ASSIGN_TUPLE_PARAM(name):
# okay, this assigns '.n' to something
del ast[i]