This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: "from __future__ import foobar;" causes wrong SyntaxError
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: blueyed, georg.brandl, nnorwitz
Priority: low Keywords:

Created on 2006-08-20 02:16 by blueyed, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg29571 - (view) Author: daniel hahler (blueyed) * Date: 2006-08-20 02:16
Instead of "SyntaxError: future feature foobar is not 
defined", you will get "SyntaxError: from __future__ 
imports must occur at the beginning of the file", if 
you use a semicolon at the end of the line (which is 
valid for existing future-imports of course).

Python 2.4.3 (#2, Apr 27 2006, 14:43:58)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for 
more information.
>>> from __future__ import foobar;
  File "<stdin>", line 1
SyntaxError: from __future__ imports must occur at 
the beginning of the file
>>> from __future__ import generators;
>>>
msg29572 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-08-20 14:33
Logged In: YES 
user_id=849994

The 2.5+ AST compiler gives the correct error message.
msg29573 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-10-28 22:58
Logged In: YES 
user_id=33168

As Georg noted, this is fixed in 2.5.  2.4 is no longer
supported.
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43861
2006-08-20 02:16:06blueyedcreate