Permalink
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
  • Loading branch information...
1 parent d69f3cc commit e7b2ad8020aef2941eb477632c4a453e7150202a @malcolmt malcolmt committed Feb 18, 2008
Showing with 3 additions and 1 deletion.
  1. +1 −1 django/utils/datastructures.py
  2. +2 −0 tests/regressiontests/datastructures/tests.py
@@ -145,7 +145,7 @@ def copy(self):
"""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):
@@ -77,6 +77,8 @@
'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')

0 comments on commit e7b2ad8

Please sign in to comment.