diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-21 21:27:44 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-21 21:27:44 +0000 |
| commit | 54546f23f09a989ee3c1c3e629eac98706b6262e (patch) | |
| tree | a2f599035eb80a6b2b2ddaa702ce5feb8efedd5a | |
| parent | dd2afd7105aa3df55a3f7f949ff31a441ed30c54 (diff) | |
Fixed #6627 -- Made dict.clear() work for SortedDicts.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7140 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/utils/datastructures.py | 4 | ||||
| -rw-r--r-- | tests/regressiontests/datastructures/tests.py | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index a2b78a31c5..4c278c0d8e 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -155,6 +155,10 @@ class SortedDict(dict): """ 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 diff --git a/tests/regressiontests/datastructures/tests.py b/tests/regressiontests/datastructures/tests.py index 172057f080..b51b4b1233 100644 --- a/tests/regressiontests/datastructures/tests.py +++ b/tests/regressiontests/datastructures/tests.py @@ -101,6 +101,12 @@ Init from sequence of tuples >>> 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']}) |
