Skip to content

Commit c9ddb7d

Browse files
author
georg.brandl
committed
#3057: Fix the MutableMapping ABC to use the 2.6 dict interface.
git-svn-id: http://svn.python.org/projects/python/trunk@64018 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent de93349 commit c9ddb7d

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

Lib/_abcoll.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,25 @@ def __contains__(self, key):
329329
else:
330330
return True
331331

332+
def iterkeys(self):
333+
return iter(self)
334+
335+
def itervalues(self):
336+
for key in self:
337+
yield self[key]
338+
339+
def iteritems(self):
340+
for key in self:
341+
yield (key, self[key])
342+
332343
def keys(self):
333-
return KeysView(self)
344+
return list(self)
334345

335346
def items(self):
336-
return ItemsView(self)
347+
return [(key, self[key]) for key in self]
337348

338349
def values(self):
339-
return ValuesView(self)
350+
return [self[key] for key in self]
340351

341352
def __eq__(self, other):
342353
return isinstance(other, Mapping) and \
@@ -363,8 +374,6 @@ def __iter__(self):
363374
for key in self._mapping:
364375
yield key
365376

366-
KeysView.register(type({}.keys()))
367-
368377

369378
class ItemsView(MappingView, Set):
370379

@@ -381,8 +390,6 @@ def __iter__(self):
381390
for key in self._mapping:
382391
yield (key, self._mapping[key])
383392

384-
ItemsView.register(type({}.items()))
385-
386393

387394
class ValuesView(MappingView):
388395

@@ -396,8 +403,6 @@ def __iter__(self):
396403
for key in self._mapping:
397404
yield self._mapping[key]
398405

399-
ValuesView.register(type({}.values()))
400-
401406

402407
class MutableMapping(Mapping):
403408

0 commit comments

Comments
 (0)