Skip to content
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

Traceback from futurize on single-line __future__ imports #194

Closed
Valloric opened this issue Feb 10, 2016 · 1 comment
Closed

Traceback from futurize on single-line __future__ imports #194

Valloric opened this issue Feb 10, 2016 · 1 comment

Comments

@Valloric
Copy link

For the following test1.py file, futurize works just fine:

from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from future import standard_library
standard_library.install_aliases()
from builtins import *

def foo():
  print('foo')

But for the same file with slightly differently organized imports:

from __future__ import ( absolute_import, unicode_literals, print_function,
                         division )
from future import standard_library
standard_library.install_aliases()
from builtins import *

def foo():
  print('foo')

futurize fails with the following traceback:

Traceback (most recent call last):
  File "/usr/local/bin/futurize", line 9, in <module>
    load_entry_point('future', 'console_scripts', 'futurize')()
  File "/home/valloric/repos/python-future/src/libfuturize/main.py", line 293, in main
    options.processes)
  File "/usr/lib/python2.7/lib2to3/refactor.py", line 706, in refactor
    items, write, doctests_only)
  File "/usr/lib/python2.7/lib2to3/refactor.py", line 301, in refactor
    self.refactor_file(dir_or_file, write, doctests_only)
  File "/usr/lib/python2.7/lib2to3/refactor.py", line 747, in refactor_file
    *args, **kwargs)
  File "/usr/lib/python2.7/lib2to3/refactor.py", line 354, in refactor_file
    tree = self.refactor_string(input, filename)
  File "/usr/lib/python2.7/lib2to3/refactor.py", line 386, in refactor_string
    self.refactor_tree(tree, name)
  File "/usr/lib/python2.7/lib2to3/refactor.py", line 460, in refactor_tree
    new = fixer.transform(node, results)
  File "/home/valloric/repos/python-future/src/libpasteurize/fixes/fix_add_all__future__imports.py", line 21, in transform
    future_import(u"unicode_literals", node)
  File "/home/valloric/repos/python-future/src/libfuturize/fixer_util.py", line 249, in future_import
    names = check_future_import(node)
  File "/home/valloric/repos/python-future/src/libfuturize/fixer_util.py", line 468, in check_future_import
    assert False, "strange import: %s" % savenode
AssertionError: strange import: from __future__ import ( absolute_import, unicode_literals, print_function,
                         division )

Futurize call: futurize -v -w -u -a -2 -n test.py

@QuLogic
Copy link
Contributor

QuLogic commented Feb 10, 2016

Dupe of #113.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants