summaryrefslogtreecommitdiff
path: root/django/http/__init__.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-06-07 18:08:47 +0200
committerClaude Paroz <claude@2xlibre.net>2012-06-07 18:08:47 +0200
commit4a103086d5c67fa4fcc53c106c9fdf644c742dd8 (patch)
tree3df00600c27f6369f7561c3b8ddf2f97d2d341d9 /django/http/__init__.py
parent706fd9adc0b6587c7f96a834c757708e64fcf615 (diff)
Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.
Thanks Vinay Sajip for the support of his django3 branch and Jannis Leidel for the review.
Diffstat (limited to 'django/http/__init__.py')
-rw-r--r--django/http/__init__.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py
index bf848deb38..30d7e5dc2f 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+from __future__ import absolute_import, unicode_literals
import datetime
import os
@@ -57,13 +57,14 @@ else:
if not _cookie_allows_colon_in_names:
def load(self, rawdata):
self.bad_cookies = set()
- super(SimpleCookie, self).load(rawdata)
+ super(SimpleCookie, self).load(smart_str(rawdata))
for key in self.bad_cookies:
del self[key]
# override private __set() method:
# (needed for using our Morsel, and for laxness with CookieError
def _BaseCookie__set(self, key, real_value, coded_value):
+ key = smart_str(key)
try:
M = self.get(key, Morsel())
M.set(key, real_value, coded_value)
@@ -131,7 +132,7 @@ def build_request_repr(request, path_override=None, GET_override=None,
except:
meta = '<could not parse>'
path = path_override if path_override is not None else request.path
- return smart_str(u'<%s\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' %
+ return smart_str('<%s\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s>' %
(request.__class__.__name__,
path,
unicode(get),
@@ -488,6 +489,7 @@ class QueryDict(MultiValueDict):
"""
output = []
if safe:
+ safe = smart_str(safe, self.encoding)
encode = lambda k, v: '%s=%s' % ((quote(k, safe), quote(v, safe)))
else:
encode = lambda k, v: urlencode({k: v})