SF patch #667730: More DictMixin
Sebastien Keim pointed out that iterkeys and __contains__ require
their own definitions so their behavior will update when the
underlying method is subclassed.
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
index 34ceb3a..f9ad471 100644
--- a/Lib/UserDict.py
+++ b/Lib/UserDict.py
@@ -90,13 +90,15 @@
except KeyError:
return False
return True
- __contains__ = has_key
+ def __contains__(self, key):
+ return self.has_key(key)
# third level takes advantage of second level definitions
def iteritems(self):
for k in self:
yield (k, self[k])
- iterkeys = __iter__
+ def iterkeys(self):
+ return self.__iter__()
# fourth level uses definitions from lower levels
def itervalues(self):