]> granicus.if.org Git - python/commitdiff
Skip over doc strings.
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 27 Feb 2006 19:56:30 +0000 (19:56 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 27 Feb 2006 19:56:30 +0000 (19:56 +0000)
Lib/compiler/future.py
Misc/NEWS

index 868b7cbb52280ba64f1886e16f43932b75c67294..414e64e8880815ba229f6ada37d9185391458ec2 100644 (file)
@@ -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()
index 2791cbe898551fdfa849a24a596212df66d6fc3c..164edc8a594a9441999a260adb9b69e0dffb8cb4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -393,6 +393,8 @@ Extension Modules
 Library
 -------
 
+- The compiler package now supports future imports after the module docstring.
+
 - Bug #1413790: zipfile now sanitizes absolute archive names that are
   not allowed by the specs.