Use "co_consts" in docstring detection.

Note: this is an upheaval because we need to pass "code" or at least
"code.co_consts" to the docstring detection routine
This commit is contained in:
rocky
2020-07-21 10:31:07 -04:00
parent f62512dd65
commit a215ee2f00
15 changed files with 75 additions and 42 deletions

View File

@@ -681,7 +681,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
assert iscode(cn.attr)
code = Code(cn.attr, self.scanner, self.currentclass)
ast = self.build_ast(code._tokens, code._customize)
ast = self.build_ast(code._tokens, code._customize, code)
self.customize(code._customize)
ast = ast[0][0][0]
@@ -728,7 +728,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
code_name = code.co_name
code = Code(code, self.scanner, self.currentclass)
ast = self.build_ast(code._tokens, code._customize)
ast = self.build_ast(code._tokens, code._customize, code)
self.customize(code._customize)
if ast[0] == "sstmt":
@@ -850,7 +850,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
self.prec = 27
code = Code(node[1].attr, self.scanner, self.currentclass)
ast = self.build_ast(code._tokens, code._customize)
ast = self.build_ast(code._tokens, code._customize, code)
self.customize(code._customize)
if node == "set_comp":
ast = ast[0][0][0]
@@ -992,7 +992,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
self.prec = 27
code = Code(node[1].attr, self.scanner, self.currentclass)
ast = self.build_ast(code._tokens, code._customize)
ast = self.build_ast(code._tokens, code._customize, code)
self.customize(code._customize)
ast = ast[0][0][0]
store = ast[3]
@@ -1142,9 +1142,8 @@ class FragmentsWalker(pysource.SourceWalker, object):
self.name = old_name
self.return_none = rn
def build_ast(
self, tokens, customize, is_lambda=False, noneInNames=False, isTopLevel=False
):
def build_ast(self, tokens, customize, code, is_lambda=False,
noneInNames=False, isTopLevel=False):
# FIXME: DRY with pysource.py