diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-03-08 04:50:37 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-03-08 04:50:37 (GMT) |
commit | 49d7149e6d12ee878fcf30d703150a5d00f3908d (patch) | |
tree | 14ab9f55ebf37924c78f5a0153848f945ebd012b /Lib/lib2to3/fixes | |
parent | 3f84b07816fc63dd4996146bdd757f6bc81c54a9 (diff) | |
download | cpython-49d7149e6d12ee878fcf30d703150a5d00f3908d.zip cpython-49d7149e6d12ee878fcf30d703150a5d00f3908d.tar.gz cpython-49d7149e6d12ee878fcf30d703150a5d00f3908d.tar.bz2 |
transform izip_longest #11424
Diffstat (limited to 'Lib/lib2to3/fixes')
-rw-r--r-- | Lib/lib2to3/fixes/fix_itertools.py | 5 | ||||
-rw-r--r-- | Lib/lib2to3/fixes/fix_itertools_imports.py | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/Lib/lib2to3/fixes/fix_itertools.py b/Lib/lib2to3/fixes/fix_itertools.py index 80790bf..63346b9 100644 --- a/Lib/lib2to3/fixes/fix_itertools.py +++ b/Lib/lib2to3/fixes/fix_itertools.py @@ -13,7 +13,7 @@ from ..fixer_util import Name class FixItertools(fixer_base.BaseFix): BM_compatible = True - it_funcs = "('imap'|'ifilter'|'izip'|'ifilterfalse')" + it_funcs = "('imap'|'ifilter'|'izip'|'izip_longest'|'ifilterfalse')" PATTERN = """ power< it='itertools' trailer< @@ -28,7 +28,8 @@ class FixItertools(fixer_base.BaseFix): def transform(self, node, results): prefix = None func = results['func'][0] - if 'it' in results and func.value != 'ifilterfalse': + if ('it' in results and + func.value not in ('ifilterfalse', 'izip_longest')): dot, it = (results['dot'], results['it']) # Remove the 'itertools' prefix = it.prefix diff --git a/Lib/lib2to3/fixes/fix_itertools_imports.py b/Lib/lib2to3/fixes/fix_itertools_imports.py index be8b90c..0ddbc7b 100644 --- a/Lib/lib2to3/fixes/fix_itertools_imports.py +++ b/Lib/lib2to3/fixes/fix_itertools_imports.py @@ -31,9 +31,10 @@ class FixItertoolsImports(fixer_base.BaseFix): if member_name in ('imap', 'izip', 'ifilter'): child.value = None child.remove() - elif member_name == 'ifilterfalse': + elif member_name in ('ifilterfalse', 'izip_longest'): node.changed() - name_node.value = 'filterfalse' + name_node.value = ('filterfalse' if member_name[1] == 'f' + else 'zip_longest') # Make sure the import statement is still sane children = imports.children[:] or [imports] |