[pypy-issue] Issue #2701: Future imports not allowed after docstrings (pypy/pypy)
issues-reply at bitbucket.org
Mon Nov 13 04:56:26 EST 2017
New issue 2701: Future imports not allowed after docstrings
The [Python language reference](https://docs.python.org/2/reference/simple_stmts.html#future) clearly states that future statements are allowed after docstrings:
> A future statement must appear near the top of the module. The only lines that can appear before a future statement are:
> - the module docstring (if any),
> - comments,
> - blank lines, and
> - other future statements.
However PyPy seems not to like it very much. See my pull request to OctoPrint: https://github.com/foosel/OctoPrint/pull/2217
The fact that in some file there is a future import, a docstring and then another future import makes PyPy crash, while CPython accepts it just fine.
SyntaxError: __future__ statements must appear at beginning of file
Code that triggers it:
from __future__ import absolute_import
from __future__ import absolute_import, division, print_function
While this obviously the best code one could write (in fact they merged my PR that fixes it), it still valid and PyPy should accept it.
More information about the pypy-issue