mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
528b7eb0b0
commit
2050b65e84
1 changed files with 2 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue