diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-18 23:08:51 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-18 23:08:51 +0000 |
| commit | e7b2ad8020aef2941eb477632c4a453e7150202a (patch) | |
| tree | ec976f91ac073f507f057d202c58db3141d8df76 | |
| parent | d69f3ccfdbf4034f76a313a91a78948b46fac553 (diff) | |
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
| -rw-r--r-- | django/utils/datastructures.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/datastructures/tests.py | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index f46b57c151..a2b78a31c5 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -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): diff --git a/tests/regressiontests/datastructures/tests.py b/tests/regressiontests/datastructures/tests.py index b5dc5d171b..172057f080 100644 --- a/tests/regressiontests/datastructures/tests.py +++ b/tests/regressiontests/datastructures/tests.py @@ -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') |
