summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3/fixes/fix_dict.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-04-10 02:50:50 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-04-10 02:50:50 (GMT)
commit3de92bf155a1fff6e48b32c5d5f0071f6669ebf0 (patch)
treeb6402aa31178767637a18a2c4b7ac2488a753df0 /Lib/lib2to3/fixes/fix_dict.py
parentb47aace423cee34acd0aae5678bcda1276adbc47 (diff)
downloadcpython-3de92bf155a1fff6e48b32c5d5f0071f6669ebf0.zip
cpython-3de92bf155a1fff6e48b32c5d5f0071f6669ebf0.tar.gz
cpython-3de92bf155a1fff6e48b32c5d5f0071f6669ebf0.tar.bz2
Merged revisions 62263 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ................ r62263 | martin.v.loewis | 2008-04-10 04:48:01 +0200 (Do, 10 Apr 2008) | 19 lines Merged revisions 62080-62262 via svnmerge from svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r62092 | collin.winter | 2008-04-01 18:27:10 +0200 (Di, 01 Apr 2008) | 1 line Add get_prev_sibling() to complement pytree's get_next_sibling(). ........ r62226 | collin.winter | 2008-04-08 21:07:56 +0200 (Di, 08 Apr 2008) | 1 line Add min() and max() to the list of special contexts that don't require adding list() calls around dict methods. ........ r62232 | collin.winter | 2008-04-09 00:12:38 +0200 (Mi, 09 Apr 2008) | 4 lines Fix for http://bugs.python.org/issue2596 This extends fix_xrange to know about the (mostly) same special contexts as fix_dict (where a special context is something that is guaranteed to fully consume the iterable), adding list() calls where appropriate. It also special-cases "x in range(y)". ........ ................
Diffstat (limited to 'Lib/lib2to3/fixes/fix_dict.py')
-rw-r--r--Lib/lib2to3/fixes/fix_dict.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/lib2to3/fixes/fix_dict.py b/Lib/lib2to3/fixes/fix_dict.py
index f76ceb4..c14a819 100644
--- a/Lib/lib2to3/fixes/fix_dict.py
+++ b/Lib/lib2to3/fixes/fix_dict.py
@@ -29,10 +29,10 @@ from .. import patcomp
from ..pgen2 import token
from . import basefix
from .util import Name, Call, LParen, RParen, ArgList, Dot, set
+from . import util
-exempt = set(["sorted", "list", "set", "any", "all", "tuple", "sum"])
-iter_exempt = exempt | set(["iter"])
+iter_exempt = util.consuming_calls | set(["iter"])
class FixDict(basefix.BaseFix):
@@ -92,7 +92,7 @@ class FixDict(basefix.BaseFix):
return results["func"].value in iter_exempt
else:
# list(d.keys()) -> list(d.keys()), etc.
- return results["func"].value in exempt
+ return results["func"].value in util.consuming_calls
if not isiter:
return False
# for ... in d.iterkeys() -> for ... in d.keys(), etc.