Commit e7b2ad80 authored by Malcolm Tredinnick's avatar Malcolm Tredinnick
Browse files

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
parent d69f3ccf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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):
+2 −0
Original line number Diff line number Diff line
@@ -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')