Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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 malcolmt authored
4 django/utils/datastructures.py
View
@@ -155,6 +155,10 @@ def __repr__(self):
"""
return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()])
+ def clear(self):
+ super(SortedDict, self).clear()
+ self.keyOrder = []
+
class MultiValueDictKeyError(KeyError):
pass
6 tests/regressiontests/datastructures/tests.py
View
@@ -101,6 +101,12 @@
>>> print repr(d)
{1: 'one', 0: 'zero', 2: 'two'}
+>>> d.clear()
+>>> d
+{}
+>>> d.keyOrder
+[]
+
### DotExpandedDict ############################################################
>>> d = DotExpandedDict({'person.1.firstname': ['Simon'], 'person.1.lastname': ['Willison'], 'person.2.firstname': ['Adrian'], 'person.2.lastname': ['Holovaty']})
Please sign in to comment.
Something went wrong with that request. Please try again.