Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.5.x] Fixed #19585 -- Fixed loading cookie value as a dict

This regression was introduced by the 'unicode_literals' patch.
Backport of f08e739 from master.
  • Loading branch information...
commit 1d03ff06bbcc726c815f26f79067692019b2c71a 1 parent b86c3dd
@claudep claudep authored
5 django/http/
@@ -1,6 +1,7 @@
from __future__ import absolute_import, unicode_literals
from django.utils.encoding import force_str
+from django.utils import six
from django.utils.six.moves import http_cookies
@@ -48,7 +49,9 @@ def value_encode(self, val):
if not _cookie_allows_colon_in_names:
def load(self, rawdata):
self.bad_cookies = set()
- super(SimpleCookie, self).load(force_str(rawdata))
+ if not six.PY3 and isinstance(rawdata, six.text_type):
+ rawdata = force_str(rawdata)
+ super(SimpleCookie, self).load(rawdata)
for key in self.bad_cookies:
del self[key]
4 tests/regressiontests/httpwrappers/
@@ -588,3 +588,7 @@ def test_httponly_after_load(self):
c['name']['httponly'] = True
+ def test_load_dict(self):
+ c = SimpleCookie()
+ c.load({'name': 'val'})
+ self.assertEqual(c['name'].value, 'val')
Please sign in to comment.
Something went wrong with that request. Please try again.