Message184277
test1.py shows that a str literal before first import from __future__ is a docstring.
test2.py shows that a str literal after first import from __future__ is not a docstring.
test2.py shows that if docstring is absent, then a single str literal between imports from __future__ does not cause SyntaxError, while it should.
test3.py shows that if docstring is present, then a str literal between imports from __future__ causes SyntaxError.
test4.py shows that if docstring is absent, then >=2 str literals between imports from __future__ cause SyntaxError.
$ 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
$ |
|
Date |
User |
Action |
Args |
2013-03-16 00:13:57 | Arfrever | set | recipients:
+ Arfrever |
2013-03-16 00:13:57 | Arfrever | set | messageid: <1363392837.6.0.139657599186.issue17434@psf.upfronthosting.co.za> |
2013-03-16 00:13:57 | Arfrever | link | issue17434 messages |
2013-03-16 00:13:57 | Arfrever | create | |
|