summaryrefslogtreecommitdiffstats
path: root/Lib/collections.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-02-05 22:54:43 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-02-05 22:54:43 (GMT)
commit554c8b856cbeb29f3fef0350846aef442832acac (patch)
tree7a12918b63e5f35787cb232b36bdbdf0890fff90 /Lib/collections.py
parentf01fe6915b329c1511548e99e0e4d34ac423f9b3 (diff)
downloadcpython-554c8b856cbeb29f3fef0350846aef442832acac.zip
cpython-554c8b856cbeb29f3fef0350846aef442832acac.tar.gz
cpython-554c8b856cbeb29f3fef0350846aef442832acac.tar.bz2
Convert test_userdict to use the collections.UserDict.
Fix-up collections.UserDict.__contains__ to work correctly when __missing__ is defined. Fix-up Mapping.__eq__ to only match instances of Mapping.
Diffstat (limited to 'Lib/collections.py')
-rw-r--r--Lib/collections.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/collections.py b/Lib/collections.py
index b883832..d06445b 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -135,6 +135,9 @@ class UserDict(MutableMapping):
def __iter__(self):
return iter(self.data)
+ # Modify __contains__ to work correctly when __missing__ is present
+ def __contains__(self, key):
+ return key in self.data
# Now, add the methods in dicts but not in MutableMapping
def __repr__(self): return repr(self.data)