-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
str literals, which are not docstrings, should not be allowed between __future__ imports #61636
Comments
test1.py shows that a str literal before first import from __future__ is a docstring. $ cat test1.py
"some text"
from __future__ import absolute_import
print(__doc__)
$ cat test2.py
from __future__ import absolute_import
"some text"
from __future__ import print_function
print(__doc__)
$ cat test3.py
"some text 1"
from __future__ import absolute_import
"some text 2"
from __future__ import print_function
$ cat test4.py
from __future__ import absolute_import
"some text 1"
"some text 2"
from __future__ import print_function
$ python3.4 test1.py
some text
$ python3.4 test2.py
None
$ python3.4 test3.py
File "test3.py", line 4
from __future__ import print_function
^
SyntaxError: from __future__ imports must occur at the beginning of the file
$ python3.4 test4.py
File "test4.py", line 4
from __future__ import print_function
^
SyntaxError: from __future__ imports must occur at the beginning of the file
$ |
Jython and PyPy properly raise SyntaxError for test2.py. |
46cadd3955d0 |
New changeset 46cadd3955d0 by Benjamin Peterson in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: