diff options
author | Raymond Hettinger <python@rcn.com> | 2008-02-05 22:54:43 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-02-05 22:54:43 (GMT) |
commit | 554c8b856cbeb29f3fef0350846aef442832acac (patch) | |
tree | 7a12918b63e5f35787cb232b36bdbdf0890fff90 /Lib/_abcoll.py | |
parent | f01fe6915b329c1511548e99e0e4d34ac423f9b3 (diff) | |
download | cpython-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/_abcoll.py')
-rw-r--r-- | Lib/_abcoll.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py index 8090b84..ba084aa 100644 --- a/Lib/_abcoll.py +++ b/Lib/_abcoll.py @@ -379,10 +379,11 @@ class Mapping(metaclass=ABCMeta): return ValuesView(self) def __eq__(self, other): - return dict(self.items()) == dict(other.items()) + return isinstance(other, Mapping) and \ + dict(self.items()) == dict(other.items()) def __ne__(self, other): - return dict(self.items()) != dict(other.items()) + return not (self == other) class MappingView(metaclass=ABCMeta): |