File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -243,6 +243,7 @@ def future_import(feature, node):
243243 # Is it a shebang or encoding line?
244244 if is_shebang_comment (node ) or is_encoding_comment (node ):
245245 shebang_encoding_idx = idx
246+ continue
246247 if is_docstring (node ):
247248 # skip over docstring
248249 continue
@@ -443,7 +444,10 @@ def check_future_import(node):
443444 hasattr (node .children [1 ], 'value' ) and
444445 node .children [1 ].value == u'__future__' ):
445446 return set ()
446- node = node .children [3 ]
447+ if node .children [3 ].type == token .LPAR :
448+ node = node .children [4 ]
449+ else :
450+ node = node .children [3 ]
447451 # now node is the import_as_name[s]
448452 # print(python_grammar.number2symbol[node.type]) # breaks sometimes
449453 if node .type == syms .import_as_names :
Original file line number Diff line number Diff line change @@ -123,6 +123,17 @@ def test_encoding_comments_kept_at_top(self):
123123 """
124124 self .convert_check (before , after )
125125
126+ def test_multiline_future_import (self ):
127+ """
128+ Issue #113: don't crash if a future import has multiple lines
129+ """
130+ text = """
131+ from __future__ import (
132+ division
133+ )
134+ """
135+ self .convert (text )
136+
126137 def test_shebang_blank_with_future_division_import (self ):
127138 """
128139 Issue #43: Is shebang line preserved as the first
You can’t perform that action at this time.
0 commit comments