#19802: HttpResponse.set_cookie doesn't handle unicode data
-------------------------------+--------------------
     Reporter:  django@…       |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Core (Other)   |    Version:  1.4
     Severity:  Normal         |   Keywords:  cookie
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 When calling HttpResponse.set_cookie as below, you get an error from
 `translate` saying it doesn't expect two variables. The backtrace is
 (relevant parts only):


 {{{
 TypeError at /js/utils/cookie/set/
 translate() takes exactly one argument (2 given)

 ...

 Traceback:
 File "/home/patrick/spng/lib/python2.7/site-
 packages/django/core/handlers/base.py" in get_response
   111.                         response = callback(request,
 *callback_args, **callback_kwargs)
 File "/home/patrick/spng/src/utils/views.py" in ajax_set_cookie
   210.             response.set_cookie(key, value)
 File "/home/patrick/spng/lib/python2.7/site-
 packages/django/http/__init__.py" in set_cookie
   657.         self.cookies[key] = value
 File "/usr/lib/python2.7/Cookie.py" in __setitem__
   592.         self.__set(key, rval, cval)
 File "/home/patrick/spng/lib/python2.7/site-
 packages/django/http/__init__.py" in _BaseCookie__set
   103.                     M.set(key, real_value, coded_value)
 File "/usr/lib/python2.7/Cookie.py" in set
   459.         if "" != translate(key, idmap, LegalChars):
 File "/usr/lib/python2.7/string.py" in translate
   493.         return s.translate(table, deletions)

 Exception Type: TypeError at /js/utils/cookie/set/
 Exception Value: translate() takes exactly one argument (2 given)
 }}}

 This is happening under Django 1.4.2 and Python 2.7.3 (both latest from
 the Ubuntu 12.10 repository). The code used to trigger this bug is:

 {{{
 from django.http import HttpResponse

 def view(request):
     response = HttpResponse()
     response.set_cookie(u'unicode_string', 'does not work!')
     return response

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19802>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to