From ca07fda2efea24cb43423b884fa4648d44e52963 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 20 Jul 2012 16:16:57 +0200 Subject: [py3] Switched to Python 3-compatible imports. xrange/range will be dealt with in a separate commit due to the huge number of changes. --- django/http/__init__.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'django/http') diff --git a/django/http/__init__.py b/django/http/__init__.py index da97506c8c..6f9d70eebd 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -16,23 +16,23 @@ except ImportError: # Python 2 from urllib import quote, urlencode from urlparse import parse_qsl, urljoin -import Cookie +from django.utils.six.moves import http_cookies # Some versions of Python 2.7 and later won't need this encoding bug fix: -_cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"') +_cookie_encodes_correctly = http_cookies.SimpleCookie().value_encode(';') == (';', '"\\073"') # See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256 -_tc = Cookie.SimpleCookie() +_tc = http_cookies.SimpleCookie() try: _tc.load(b'foo:bar=1') _cookie_allows_colon_in_names = True -except Cookie.CookieError: +except http_cookies.CookieError: _cookie_allows_colon_in_names = False if _cookie_encodes_correctly and _cookie_allows_colon_in_names: - SimpleCookie = Cookie.SimpleCookie + SimpleCookie = http_cookies.SimpleCookie else: - Morsel = Cookie.Morsel + Morsel = http_cookies.Morsel - class SimpleCookie(Cookie.SimpleCookie): + class SimpleCookie(http_cookies.SimpleCookie): if not _cookie_encodes_correctly: def value_encode(self, val): # Some browsers do not support quoted-string from RFC 2109, @@ -73,9 +73,9 @@ else: M = self.get(key, Morsel()) M.set(key, real_value, coded_value) dict.__setitem__(self, key, M) - except Cookie.CookieError: + except http_cookies.CookieError: self.bad_cookies.add(key) - dict.__setitem__(self, key, Cookie.Morsel()) + dict.__setitem__(self, key, http_cookies.Morsel()) from django.conf import settings @@ -495,11 +495,11 @@ class QueryDict(MultiValueDict): def parse_cookie(cookie): if cookie == '': return {} - if not isinstance(cookie, Cookie.BaseCookie): + if not isinstance(cookie, http_cookies.BaseCookie): try: c = SimpleCookie() c.load(cookie) - except Cookie.CookieError: + except http_cookies.CookieError: # Invalid cookie return {} else: -- cgit v1.3