Thanks to visit codestin.com
Credit goes to github.com

Skip to content

futurize breaks on multiline future imports #232

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

Closed
JelleZijlstra opened this issue Aug 30, 2016 · 2 comments
Closed

futurize breaks on multiline future imports #232

JelleZijlstra opened this issue Aug 30, 2016 · 2 comments

Comments

@JelleZijlstra
Copy link

When a future import spans multiple lines, futurize crashes trying to refactor it.

$ cat weirdimport.py 
from __future__ import (absolute_import, division,
                        unicode_literals)

print 3
$ futurize weirdimport.py 
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: ws_comma
Traceback (most recent call last):
  File ".../bin/futurize", line 9, in <module>
    load_entry_point('future==0.15.2', 'console_scripts', 'futurize')()
  File ".../site-packages/future-0.15.2-py2.7.egg/libfuturize/main.py", line 293, in main
    options.processes)
  File ".../lib2to3/refactor.py", line 706, in refactor
    items, write, doctests_only)
  File ".../lib2to3/refactor.py", line 301, in refactor
    self.refactor_file(dir_or_file, write, doctests_only)
  File ".../lib2to3/refactor.py", line 747, in refactor_file
    *args, **kwargs)
  File ".../lib2to3/refactor.py", line 354, in refactor_file
    tree = self.refactor_string(input, filename)
  File ".../lib2to3/refactor.py", line 386, in refactor_string
    self.refactor_tree(tree, name)
  File ".../lib2to3/refactor.py", line 460, in refactor_tree
    new = fixer.transform(node, results)
  File ".../site-packages/future-0.15.2-py2.7.egg/libfuturize/fixes/fix_print_with_import.py", line 20, in transform
    future_import(u'print_function', node)
  File ".../site-packages/future-0.15.2-py2.7.egg/libfuturize/fixer_util.py", line 210, in future_import
    names = check_future_import(node)
  File ".../site-packages/future-0.15.2-py2.7.egg/libfuturize/fixer_util.py", line 426, in check_future_import
    assert False, "strange import: %s" % savenode
AssertionError: strange import: from __future__ import (absolute_import, division,
                        unicode_literals)

$ futurize --version
0.15.2
@QuLogic
Copy link
Contributor

QuLogic commented Aug 30, 2016

Dupe of #113.

@JelleZijlstra
Copy link
Author

Thanks, closing this one

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

2 participants