Ticket #19585: 19585-1.diff

File 19585-1.diff, 1.3 KB (added by Claude Paroz, 11 years ago)
  • django/http/cookie.py

    diff --git a/django/http/cookie.py b/django/http/cookie.py
    index 78adb09..50ff549 100644
    a b  
    11from __future__ import absolute_import, unicode_literals
    22
    33from django.utils.encoding import force_str
     4from django.utils import six
    45from django.utils.six.moves import http_cookies
    56
    67
    else:  
    4849        if not _cookie_allows_colon_in_names:
    4950            def load(self, rawdata):
    5051                self.bad_cookies = set()
    51                 super(SimpleCookie, self).load(force_str(rawdata))
     52                if not six.PY3 and isinstance(rawdata, six.text_type):
     53                    rawdata = force_str(rawdata)
     54                super(SimpleCookie, self).load(rawdata)
    5255                for key in self.bad_cookies:
    5356                    del self[key]
    5457
  • tests/regressiontests/httpwrappers/tests.py

    diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py
    index 67172d9..c76d8ea 100644
    a b class CookieTests(unittest.TestCase):  
    588588        c['name']['httponly'] = True
    589589        self.assertTrue(c['name']['httponly'])
    590590
     591    def test_load_dict(self):
     592        c = SimpleCookie()
     593        c.load({'name': 'val'})
     594        self.assertEqual(c['name'].value, 'val')
Back to Top