diff options
Diffstat (limited to 'Lib/lib2to3/fixes/fix_map.py')
-rw-r--r-- | Lib/lib2to3/fixes/fix_map.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Lib/lib2to3/fixes/fix_map.py b/Lib/lib2to3/fixes/fix_map.py index cf8f351..77d66c4 100644 --- a/Lib/lib2to3/fixes/fix_map.py +++ b/Lib/lib2to3/fixes/fix_map.py @@ -49,8 +49,7 @@ class FixMap(fixer_base.ConditionalFix): > | power< - 'map' - args=trailer< '(' [any] ')' > + 'map' trailer< '(' [arglist=any] ')' > > """ @@ -66,13 +65,22 @@ class FixMap(fixer_base.ConditionalFix): new.prefix = "" new = Call(Name("list"), [new]) elif "map_lambda" in results: - new = ListComp(results.get("xp").clone(), - results.get("fp").clone(), - results.get("it").clone()) + new = ListComp(results["xp"].clone(), + results["fp"].clone(), + results["it"].clone()) else: if "map_none" in results: new = results["arg"].clone() else: + if "arglist" in results: + args = results["arglist"] + if args.type == syms.arglist and \ + args.children[0].type == token.NAME and \ + args.children[0].value == "None": + self.warning(node, "cannot convert map(None, ...) " + "with multiple arguments because map() " + "now truncates to the shortest sequence") + return if in_special_context(node): return None new = node.clone() |