﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19802	HttpResponse.set_cookie doesn't handle unicode data	django@…	QingFeng	"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

}}}
    "	Bug	closed	HTTP handling	1.5	Normal	fixed	cookie	semenov@…	Ready for checkin	1	0	0	0	0	0
