Commits

Vincent Legoll  committed a527fd2

Fix Remaining test failure.
Stick to cpython2.7 Exception message.
Move handling of 'must occur at the beginning of the file' to after
other SyntaxError.
Remove special casing of __future__ star import.

  • Participants
  • Parent commits 629398a

Comments (0)

Files changed (1)

File pypy/interpreter/astcompiler/codegen.py

         star_import = len(imp.names) == 1 and first.name == "*"
         # Various error checking for future imports.
         if imp.module == "__future__":
-            last_line, last_offset = self.compile_info.last_future_import
-            if imp.lineno > last_line or \
-                    imp.lineno == last_line and imp.col_offset > last_offset:
-                self.error("__future__ statements must appear at beginning " \
-                               "of file", imp)
-            if star_import:
-                self.error("* not valid in __future__ imports", imp)
             compiler = space.createcompiler()
             for alias in imp.names:
                 assert isinstance(alias, ast.alias)
                         self.error("not a chance", imp)
                     self.error("future feature %s is not defined" %
                                (alias.name,), imp)
+            last_line, last_offset = self.compile_info.last_future_import
+            if imp.lineno > last_line or \
+                    imp.lineno == last_line and imp.col_offset > last_offset:
+                self.error("from __future__ imports must occur at the "
+                           "beginning of the file", imp)
         if imp.level == 0 and \
                 not self.compile_info.flags & consts.CO_FUTURE_ABSOLUTE_IMPORT:
             level = -1