summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-07-25 19:10:40 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-07-25 19:10:40 +0200
commitf3c9a16a423c90baaf3804cb050d320741f799a2 (patch)
tree67b200a1fb631ee1a9b70e678ebcfdd45d9beb9d
parent69f4856f23ff61b8816901c1f3369c7d8237d97c (diff)
Fixed QueryDict.setlistdefault.
It was broken by a seemingly innocuous change in MultiValueDict. Document the pitfall for now. This is fragile and should be considered for refactoring.
-rw-r--r--django/utils/datastructures.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index ce5218deb3..4d265ca719 100644
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -339,7 +339,8 @@ class MultiValueDict(dict):
def setdefault(self, key, default=None):
if key not in self:
self[key] = default
- return default
+ # Do not return default here because __setitem__() may store
+ # another value -- QueryDict.__setitem__() does. Look it up.
return self[key]
def setlistdefault(self, key, default_list=None):
@@ -347,7 +348,8 @@ class MultiValueDict(dict):
if default_list is None:
default_list = []
self.setlist(key, default_list)
- return default_list
+ # Do not return default_list here because setlist() may store
+ # another value -- QueryDict.setlist() does. Look it up.
return self.getlist(key)
def appendlist(self, key, value):