This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dvarrazzo
Recipients
Date 2006-03-05.04:18:31
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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.
History
Date User Action Args
2007-08-23 14:38:14adminlinkissue1443328 messages
2007-08-23 14:38:14admincreate