summaryrefslogtreecommitdiff
path: root/Lib/UserDict.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-07 17:40:42 +0000
committerGuido van Rossum <guido@python.org>2001-08-07 17:40:42 +0000
commit3564d69dbd3ee11247356e09dc1fa1ecefbccdf7 (patch)
treea5e3373ddf063fcd6939ef0e4155340094bcb526 /Lib/UserDict.py
parentc392517f6953cfb7cc84250f8de0b2fe5fe571e4 (diff)
downloadcpython-3564d69dbd3ee11247356e09dc1fa1ecefbccdf7.tar.gz
Remove the __iter__ method from the UserDict class -- it can silently
break old code (in extreme cases). See SF bug #448153. Add a new subclass IterableUserDict that has the __iter__ method. Note that for new projects, unless backwards compatibility with pre-2.2 Python is required, subclassing 'dictionary' is recommended; UserDict might become deprecated.
Diffstat (limited to 'Lib/UserDict.py')
-rw-r--r--Lib/UserDict.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
index fbd601a88f..b806ac1603 100644
--- a/Lib/UserDict.py
+++ b/Lib/UserDict.py
@@ -47,5 +47,7 @@ class UserDict:
return self.data.popitem()
def __contains__(self, key):
return key in self.data
+
+class IterableUserDict(UserDict):
def __iter__(self):
return iter(self.data)