Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #6627 -- Made dict.clear() work for SortedDicts.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7140 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 54546f23f09a989ee3c1c3e629eac98706b6262e 1 parent dd2afd7
Malcolm Tredinnick authored February 21, 2008
4  django/utils/datastructures.py
@@ -155,6 +155,10 @@ def __repr__(self):
155 155
         """
156 156
         return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()])
157 157
 
  158
+    def clear(self):
  159
+        super(SortedDict, self).clear()
  160
+        self.keyOrder = []
  161
+
158 162
 class MultiValueDictKeyError(KeyError):
159 163
     pass
160 164
 
6  tests/regressiontests/datastructures/tests.py
@@ -101,6 +101,12 @@
101 101
 >>> print repr(d)
102 102
 {1: 'one', 0: 'zero', 2: 'two'}
103 103
 
  104
+>>> d.clear()
  105
+>>> d
  106
+{}
  107
+>>> d.keyOrder
  108
+[]
  109
+
104 110
 ### DotExpandedDict ############################################################
105 111
 
106 112
 >>> d = DotExpandedDict({'person.1.firstname': ['Simon'], 'person.1.lastname': ['Willison'], 'person.2.firstname': ['Adrian'], 'person.2.lastname': ['Holovaty']})

0 notes on commit 54546f2

Please sign in to comment.
Something went wrong with that request. Please try again.