Restored backward compatibility of pickling http.cookies.Morsel. It was

broken after converting instance attributes to properies in issue #2211.
This commit is contained in:
Serhiy Storchaka 2015-03-18 18:03:40 +02:00
parent cb7e5f6f08
commit 6c32585f67
2 changed files with 32 additions and 0 deletions

View file

@ -377,6 +377,18 @@ class Morsel(dict):
self._value = val
self._coded_value = coded_val
def __getstate__(self):
return {
'key': self._key,
'value': self._value,
'coded_value': self._coded_value,
}
def __setstate__(self, state):
self._key = state['key']
self._value = state['value']
self._coded_value = state['coded_value']
def output(self, attrs=None, header="Set-Cookie:"):
return "%s %s" % (header, self.OutputString(attrs))