From: Guido van Rossum Date: Tue, 7 Aug 2001 17:40:42 +0000 (+0000) Subject: Remove the __iter__ method from the UserDict class -- it can silently X-Git-Tag: v2.2a3~769 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2050b65e84c01651f1b37b7ab058ec958fd14a53;p=python 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. --- 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)