Fixed #6611 -- When copying a SortedDict, make a new copy of the keys list.

Thanks, Jeremy Dunck.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7129 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2008-02-18 23:08:51 +00:00
parent d69f3ccfdb
commit e7b2ad8020
2 changed files with 3 additions and 1 deletions

View File

@ -145,7 +145,7 @@ class SortedDict(dict):
"""Returns a copy of this object."""
# This way of initializing the copy means it works for subclasses, too.
obj = self.__class__(self)
obj.keyOrder = self.keyOrder
obj.keyOrder = self.keyOrder[:]
return obj
def __repr__(self):

View File

@ -77,6 +77,8 @@ MultiValueDictKeyError: "Key 'lastname' not found in <MultiValueDict: {'position
'not one'
>>> d.keys() == d.copy().keys()
True
>>> d2 = d.copy()
>>> d2['four'] = 'four'
>>> print repr(d)
{'one': 'not one', 'two': 'two', 'three': 'three'}
>>> d.pop('one', 'missing')