You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
2to3 incorrectly handles multi-line imports from __future__ #57082
If import from __future__ is written in multiple lines, then a parser internally used by 2to3 recognizes only the first line. (However Python interpreter properly supports multi-line imports from __future__.)
test1.py contains multi-line import from __future__.
test2.py contains single-line import from __future__.
2to3 properly handles test2.py and improperly handles test1.py.
lunaryorn commented on Sep 2, 2011
lunaryornmannequin
Mannequin
More actions
More precisely, the bug is, that 2to3 refactors the "print()" invocation in "test1.py" though it shouldn't because a "print_function" future import is present at the beginning of "test1.py". The cross-check with "test2.py" shows that this is due to the multi-line future import in "test1.py" because the line-break in the import statement is the only difference between both files.
jdekloe commented on Oct 17, 2015
jdekloemannequin
Mannequin
More actions
still having this issue with 2to3 from python-tools-2.7.8-11 as packaged by Fedora 21.
Any progress since 2011?
Activity
Arfrever commentedon Aug 31, 2011
$ cat test1.py from __future__ import (absolute_import, division, print_function, unicode_literals)merwok commentedon Sep 2, 2011
I don’t understand what the bug is.
Arfrever commentedon Sep 2, 2011
If import from __future__ is written in multiple lines, then a parser internally used by 2to3 recognizes only the first line. (However Python interpreter properly supports multi-line imports from __future__.)
test1.py contains multi-line import from __future__.
test2.py contains single-line import from __future__.
2to3 properly handles test2.py and improperly handles test1.py.
lunaryorn commentedon Sep 2, 2011
More precisely, the bug is, that 2to3 refactors the "print()" invocation in "test1.py" though it shouldn't because a "print_function" future import is present at the beginning of "test1.py". The cross-check with "test2.py" shows that this is due to the multi-line future import in "test1.py" because the line-break in the import statement is the only difference between both files.
jdekloe commentedon Oct 17, 2015
still having this issue with 2to3 from python-tools-2.7.8-11 as packaged by Fedora 21.
Any progress since 2011?