From 59df07738c05db85f5cfb8da61d3ec36c2a55987 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 14 Mar 2016 10:24:51 -0400 Subject: [PATCH] Simplified _cookie_allows_colon_in_names condition. --- django/http/cookie.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/django/http/cookie.py b/django/http/cookie.py index 2714a30638..344e59661f 100644 --- a/django/http/cookie.py +++ b/django/http/cookie.py @@ -6,13 +6,8 @@ from django.utils import six from django.utils.encoding import force_str from django.utils.six.moves import http_cookies -# See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256 -_tc = http_cookies.SimpleCookie() -try: - _tc.load(str('foo:bar=1')) - _cookie_allows_colon_in_names = True -except http_cookies.CookieError: - _cookie_allows_colon_in_names = False +# http://bugs.python.org/issue2193 is fixed in Python 3.3+. +_cookie_allows_colon_in_names = six.PY3 # Cookie pickling bug is fixed in Python 2.7.9 and Python 3.4.3+ # http://bugs.python.org/issue22775 @@ -40,7 +35,7 @@ else: if not _cookie_allows_colon_in_names: def load(self, rawdata): self.bad_cookies = set() - if six.PY2 and isinstance(rawdata, six.text_type): + if isinstance(rawdata, six.text_type): rawdata = force_str(rawdata) super(SimpleCookie, self).load(rawdata) for key in self.bad_cookies: