New submission from Arfrever Frehtes Taifersar Arahesis: 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 $ ---------- components: Interpreter Core messages: 184277 nosy: Arfrever priority: normal severity: normal status: open title: str literals, which are not docstrings, should not be allowed between __future__ imports versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17434> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com