Title: pickle protocol 2 is incompatible(?) with Cookie module
Type: Stage:
Components: Library (Lib) Versions:
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, insomnike, manlioperillo
Priority: normal Keywords:

Created on 2004-06-02 09:12 by manlioperillo, last changed 2004-06-05 19:46 by akuchling. This issue is now closed.

Messages (4)
msg20975 - (view) Author: Manlio Perillo (manlioperillo) Date: 2004-06-02 09:12
>>> sys.version
'2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit
>>> sys.platform
>>> sys.getwindowsversion()
(5, 1, 2600, 2, '')

I don't know if this is a bug of Cookie module or of

When I dump a Cookie instance with protocol = 2, the
data is 'corrupted'.
With protocol = 1 there are no problems.

Here is an example:

>>> s = 'Set-Cookie: key=value; path=/; expires=Fri,
21-May-2004 10:40:51 GMT'
>>> c = Cookie.BaseCookie(s)
>>> print c
Set-Cookie: key=value; expires=Fri,; Path=/;

>>> buf = pickle.dumps(c, protocol = 2)
>>> print pickle.loads(buf)
Set-Cookie: key=Set-Cookie: key=value; expires=Fri,;

>>> buf = pickle.dumps(c, protocol = 1)
>>> print pickle.loads(buf)
Set-Cookie: key=value; expires=Fri,; Path=/;

Thanks and regards  Manlio Perillo
msg20976 - (view) Author: Aaron Brady (insomnike) Date: 2004-06-05 15:44
Logged In: YES 

Okay, I've looked at the output from protocols 0, 1 and 2
from, and after nearly two hours of looking
into this, I think the problem lies with the fact that both
Morsel and BaseCookie derive from dict and override __setitem__.

I think that this stems from BUILD using __dict__ directly,
but lack the internal knowledge of pickle to investigate
msg20977 - (view) Author: Aaron Brady (insomnike) Date: 2004-06-05 15:57
Logged In: YES 

#826897 appears to be a dupe of this.

__setitem__ is called for the items in the dict *before* the
instance variables are set.
msg20978 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-06-05 19:46
Logged In: YES 

Date User Action Args
2004-06-02 09:12:36manlioperillocreate