[ python-Bugs-1443328 ] Pickle protocol 2 fails on private slots.
SourceForge.net
noreply at sourceforge.net
Sun Mar 5 05:18:31 CET 2006
Bugs item #1443328, was opened at 2006-03-05 04:18
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1443328&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Daniele Varrazzo (dvarrazzo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pickle protocol 2 fails on private slots.
Initial Comment:
The pickling protocol 2 can manage new style objects
defining __slots__ and without __dict__. Anyway it
fails when one of the slots is "private".
>>> class C1(object):
__slots__ = ["__priv"]
def __init__(self):
self.__priv = 42
def get_priv(self):
return self.__priv
>>> C1().get_priv()
42
>>> import pickle
>>> pickle.loads(pickle.dumps(C1(), 2)).get_priv()
Traceback (most recent call last):
File "<pyshell#258>", line 1, in -toplevel-
pickle.loads(pickle.dumps(C1(), 2)).get_priv()
File "<pyshell#255>", line 6, in get_priv
return self.__priv
AttributeError: _C1__priv
of course redefining __getstate__ and __setstate__
bypasses the problem.
the cPickle module shows the same issue.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1443328&group_id=5470
More information about the Python-bugs-list
mailing list