Merged revisions 61724-61824 via svnmerge from

svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3

........
  r61730 | martin.v.loewis | 2008-03-22 02:20:58 +0100 (Sa, 22 Mär 2008) | 2 lines

  More explicit relative imports.
........
  r61755 | david.wolever | 2008-03-22 21:33:52 +0100 (Sa, 22 Mär 2008) | 1 line

  Fixing #2446 -- 2to3 now translates 'import foo' to 'from . import foo'
........
  r61824 | david.wolever | 2008-03-24 01:30:24 +0100 (Mo, 24 Mär 2008) | 3 lines

  Fixed a bug where 'from itertools import izip' would return 'from itertools import'
........
This commit is contained in:
Martin v. Löwis 2008-03-24 00:46:53 +00:00
parent 440ca772f3
commit 966d0e0930
6 changed files with 62 additions and 23 deletions

View file

@ -17,6 +17,9 @@ class FixItertoolsImports(basefix.BaseFix):
# Handle 'import ... as ...'
continue
if child.value in ('imap', 'izip', 'ifilter'):
# The value must be set to none in case child == import,
# so that the test for empty imports will work out
child.value = None
child.remove()
elif child.value == 'ifilterfalse':
node.changed()
@ -34,10 +37,9 @@ class FixItertoolsImports(basefix.BaseFix):
if unicode(children[-1]) == ',':
children[-1].remove()
# If there is nothing left, return a blank line
# If there are no imports left, just get rid of the entire statement
if not (imports.children or getattr(imports, 'value', None)):
new = BlankLine()
new.prefix = node.get_prefix()
else:
new = node
return new
p = node.get_prefix()
node = BlankLine()
node.prefix = p
return node