diff options
author | Guido van Rossum <guido@python.org> | 2001-08-07 17:40:42 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-07 17:40:42 (GMT) |
commit | 2050b65e84c01651f1b37b7ab058ec958fd14a53 (patch) | |
tree | a569ec4a3718c2e41c0cfced8cdda0e57f85c439 /Lib/UserDict.py | |
parent | 528b7eb0b0fa5a6bbbf5f3dfbfb7c356edaf031c (diff) | |
download | cpython-2050b65e84c01651f1b37b7ab058ec958fd14a53.zip cpython-2050b65e84c01651f1b37b7ab058ec958fd14a53.tar.gz cpython-2050b65e84c01651f1b37b7ab058ec958fd14a53.tar.bz2 |
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.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/UserDict.py b/Lib/UserDict.py index fbd601a..b806ac1 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) |