mirror of https://github.com/django/django.git
Refs #23919 -- Removed Python 2 version check in django.http.cookie.
This commit is contained in:
parent
eb0b921c29
commit
fedda6d9bd
|
@ -1,28 +1,20 @@
|
||||||
import sys
|
import sys
|
||||||
from http import cookies
|
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
|
# http://bugs.python.org/issue22775
|
||||||
cookie_pickles_properly = (
|
if sys.version_info >= (3, 4, 3):
|
||||||
(sys.version_info[:2] == (2, 7) and sys.version_info >= (2, 7, 9)) or
|
|
||||||
sys.version_info >= (3, 4, 3)
|
|
||||||
)
|
|
||||||
|
|
||||||
if cookie_pickles_properly:
|
|
||||||
SimpleCookie = cookies.SimpleCookie
|
SimpleCookie = cookies.SimpleCookie
|
||||||
else:
|
else:
|
||||||
Morsel = cookies.Morsel
|
Morsel = cookies.Morsel
|
||||||
|
|
||||||
class SimpleCookie(cookies.SimpleCookie):
|
class SimpleCookie(cookies.SimpleCookie):
|
||||||
if not cookie_pickles_properly:
|
def __setitem__(self, key, value):
|
||||||
def __setitem__(self, key, value):
|
if isinstance(value, Morsel):
|
||||||
# Apply the fix from http://bugs.python.org/issue22775 where
|
# allow assignment of constructed Morsels (e.g. for pickling)
|
||||||
# it's not fixed in Python itself
|
dict.__setitem__(self, key, value)
|
||||||
if isinstance(value, Morsel):
|
else:
|
||||||
# allow assignment of constructed Morsels (e.g. for pickling)
|
super(SimpleCookie, self).__setitem__(key, value)
|
||||||
dict.__setitem__(self, key, value)
|
|
||||||
else:
|
|
||||||
super(SimpleCookie, self).__setitem__(key, value)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_cookie(cookie):
|
def parse_cookie(cookie):
|
||||||
|
|
Loading…
Reference in New Issue