summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-01-19 20:06:03 -0500
committerTim Graham <timograham@gmail.com>2017-01-19 20:06:03 -0500
commitfedda6d9bdbb7624ae36a791ef91aeca9ba6ab8d (patch)
tree38e1a6e1f67c6fa5d24d3de7bf69558627203886
parenteb0b921c29ace8643a5a4cd136c433727c53dead (diff)
Refs #23919 -- Removed Python 2 version check in django.http.cookie.
-rw-r--r--django/http/cookie.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/django/http/cookie.py b/django/http/cookie.py
index f45ef11295..fb0a7786ef 100644
--- a/django/http/cookie.py
+++ b/django/http/cookie.py
@@ -1,28 +1,20 @@
import sys
from http import cookies
-# Cookie pickling bug is fixed in Python 2.7.9 and Python 3.4.3+
+# Cookie pickling bug is fixed in Python 3.4.3+
# http://bugs.python.org/issue22775
-cookie_pickles_properly = (
- (sys.version_info[:2] == (2, 7) and sys.version_info >= (2, 7, 9)) or
- sys.version_info >= (3, 4, 3)
-)
-
-if cookie_pickles_properly:
+if sys.version_info >= (3, 4, 3):
SimpleCookie = cookies.SimpleCookie
else:
Morsel = cookies.Morsel
class SimpleCookie(cookies.SimpleCookie):
- if not cookie_pickles_properly:
- def __setitem__(self, key, value):
- # Apply the fix from http://bugs.python.org/issue22775 where
- # it's not fixed in Python itself
- if isinstance(value, Morsel):
- # allow assignment of constructed Morsels (e.g. for pickling)
- dict.__setitem__(self, key, value)
- else:
- super(SimpleCookie, self).__setitem__(key, value)
+ def __setitem__(self, key, value):
+ if isinstance(value, Morsel):
+ # allow assignment of constructed Morsels (e.g. for pickling)
+ dict.__setitem__(self, key, value)
+ else:
+ super(SimpleCookie, self).__setitem__(key, value)
def parse_cookie(cookie):