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 alga
Recipients alga
Date 2010-02-03.18:18:42
SpamBayes Score 8.701799e-10
Marked as misclassified No
Message-id <1265221125.46.0.788083310396.issue7848@psf.upfronthosting.co.za>
In-reply-to
Content
When copy.copy is used on an object whose __getstate__ returns 0, it can produce a corrupt copy of an object:

>>> import copy
>>> class Foo(object):
...     def __init__(self):
...        self.value = 0
...     def __getstate__(self):
...        return self.value
...     def __setstate__(self, v):
...        self.value = v
... 
>>> one = Foo()
>>> two = copy.copy(one)
>>> two.value
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Foo' object has no attribute 'value'

Pickling/unpickling works fine for this object, so this appears to be a bug in copy._reconstruct.

This is not a contrived example, BTrees.Length.Length from ZODB uses such a __getstate__.
History
Date User Action Args
2010-02-03 18:18:45algasetrecipients: + alga
2010-02-03 18:18:45algasetmessageid: <1265221125.46.0.788083310396.issue7848@psf.upfronthosting.co.za>
2010-02-03 18:18:43algalinkissue7848 messages
2010-02-03 18:18:43algacreate