mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
Skip over doc strings.
This commit is contained in:
parent
b9eb5510e6
commit
415ed937c2
2 changed files with 10 additions and 1 deletions
|
@ -22,7 +22,14 @@ class FutureParser:
|
|||
|
||||
def visitModule(self, node):
|
||||
stmt = node.node
|
||||
found_docstring = False
|
||||
for s in stmt.nodes:
|
||||
# Skip over docstrings
|
||||
if not found_docstring and isinstance(s, ast.Discard) \
|
||||
and isinstance(s.expr, ast.Const) \
|
||||
and isinstance(s.expr.value, str):
|
||||
found_docstring = True
|
||||
continue
|
||||
if not self.check_stmt(s):
|
||||
break
|
||||
|
||||
|
@ -50,7 +57,7 @@ class BadFutureParser:
|
|||
return
|
||||
if node.modname != "__future__":
|
||||
return
|
||||
raise SyntaxError, "invalid future statement"
|
||||
raise SyntaxError, "invalid future statement " + repr(node)
|
||||
|
||||
def find_futures(node):
|
||||
p1 = FutureParser()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue