summaryrefslogtreecommitdiffstats
path: root/Lib/compiler
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-02-27 19:56:30 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-02-27 19:56:30 (GMT)
commit415ed937c21f0d563fb11a20189831b908673462 (patch)
tree022cd5e9955db1b55dc5583a50e10ae2f7207c0f /Lib/compiler
parentb9eb5510e676627759d804271dc3b46682291cc2 (diff)
downloadcpython-415ed937c21f0d563fb11a20189831b908673462.zip
cpython-415ed937c21f0d563fb11a20189831b908673462.tar.gz
cpython-415ed937c21f0d563fb11a20189831b908673462.tar.bz2
Skip over doc strings.
Diffstat (limited to 'Lib/compiler')
-rw-r--r--Lib/compiler/future.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/compiler/future.py b/Lib/compiler/future.py
index 868b7cbb..414e64e 100644
--- a/Lib/compiler/future.py
+++ b/Lib/compiler/future.py
@@ -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()