summaryrefslogtreecommitdiffstats
path: root/Lib/http/cookies.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-02 20:18:25 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-02 20:18:25 (GMT)
commit8cf7c1cff0f1176387118826fffdf1c517405f3a (patch)
tree3d417f11c533d4a72568492aa892aefc94e49320 /Lib/http/cookies.py
parenta5c9c37dd51cdec4e858fde6a42bf6b2868cae48 (diff)
downloadcpython-8cf7c1cff0f1176387118826fffdf1c517405f3a.zip
cpython-8cf7c1cff0f1176387118826fffdf1c517405f3a.tar.gz
cpython-8cf7c1cff0f1176387118826fffdf1c517405f3a.tar.bz2
Issue #22775: Fixed unpickling of http.cookies.SimpleCookie with protocol 2
and above. Patch by Tim Graham.
Diffstat (limited to 'Lib/http/cookies.py')
-rw-r--r--Lib/http/cookies.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py
index 556d101..a6de6d5 100644
--- a/Lib/http/cookies.py
+++ b/Lib/http/cookies.py
@@ -486,8 +486,12 @@ class BaseCookie(dict):
def __setitem__(self, key, value):
"""Dictionary style assignment."""
- rval, cval = self.value_encode(value)
- self.__set(key, rval, cval)
+ if isinstance(value, Morsel):
+ # allow assignment of constructed Morsels (e.g. for pickling)
+ dict.__setitem__(self, key, value)
+ else:
+ rval, cval = self.value_encode(value)
+ self.__set(key, rval, cval)
def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"):
"""Return a string suitable for HTTP."""