mirror of https://github.com/python/cpython
#3057: Fix the MutableMapping ABC to use the 2.6 dict interface.
This commit is contained in:
parent
3bed4aeea5
commit
60fbf7f8bb
|
@ -329,14 +329,25 @@ class Mapping(Sized, Iterable, Container):
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def iterkeys(self):
|
||||||
|
return iter(self)
|
||||||
|
|
||||||
|
def itervalues(self):
|
||||||
|
for key in self:
|
||||||
|
yield self[key]
|
||||||
|
|
||||||
|
def iteritems(self):
|
||||||
|
for key in self:
|
||||||
|
yield (key, self[key])
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
return KeysView(self)
|
return list(self)
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
return ItemsView(self)
|
return [(key, self[key]) for key in self]
|
||||||
|
|
||||||
def values(self):
|
def values(self):
|
||||||
return ValuesView(self)
|
return [self[key] for key in self]
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return isinstance(other, Mapping) and \
|
return isinstance(other, Mapping) and \
|
||||||
|
@ -363,8 +374,6 @@ class KeysView(MappingView, Set):
|
||||||
for key in self._mapping:
|
for key in self._mapping:
|
||||||
yield key
|
yield key
|
||||||
|
|
||||||
KeysView.register(type({}.keys()))
|
|
||||||
|
|
||||||
|
|
||||||
class ItemsView(MappingView, Set):
|
class ItemsView(MappingView, Set):
|
||||||
|
|
||||||
|
@ -381,8 +390,6 @@ class ItemsView(MappingView, Set):
|
||||||
for key in self._mapping:
|
for key in self._mapping:
|
||||||
yield (key, self._mapping[key])
|
yield (key, self._mapping[key])
|
||||||
|
|
||||||
ItemsView.register(type({}.items()))
|
|
||||||
|
|
||||||
|
|
||||||
class ValuesView(MappingView):
|
class ValuesView(MappingView):
|
||||||
|
|
||||||
|
@ -396,8 +403,6 @@ class ValuesView(MappingView):
|
||||||
for key in self._mapping:
|
for key in self._mapping:
|
||||||
yield self._mapping[key]
|
yield self._mapping[key]
|
||||||
|
|
||||||
ValuesView.register(type({}.values()))
|
|
||||||
|
|
||||||
|
|
||||||
class MutableMapping(Mapping):
|
class MutableMapping(Mapping):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue