mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
f01fe6915b
commit
554c8b856c
3 changed files with 39 additions and 41 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue