From 415ed937c21f0d563fb11a20189831b908673462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Mon, 27 Feb 2006 19:56:30 +0000 Subject: Skip over doc strings. --- Lib/compiler/future.py | 9 ++++++++- Misc/NEWS | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) 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() diff --git a/Misc/NEWS b/Misc/NEWS index 2791cbe..164edc8 100644 --- 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. -- cgit v0.12