diff options
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] |