Issue #22775: Fixed unpickling of Cookie.SimpleCookie with protocol 2.
Patch by Tim Graham.
diff --git a/Lib/Cookie.py b/Lib/Cookie.py
index d674437..0b15531 100644
--- a/Lib/Cookie.py
+++ b/Lib/Cookie.py
@@ -591,8 +591,12 @@
 
     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)
     # end __setitem__
 
     def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"):