Browse files

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.
  • Loading branch information...
aaugustin committed Jul 25, 2012
1 parent 69f4856 commit f3c9a16a423c90baaf3804cb050d320741f799a2
Showing with 4 additions and 2 deletions.
  1. +4 −2 django/utils/
@@ -339,15 +339,17 @@ def setlist(self, key, list_):
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):
if key not in self:
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):

0 comments on commit f3c9a16

Please sign in to comment.