Message98793
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__. |
|
Date |
User |
Action |
Args |
2010-02-03 18:18:45 | alga | set | recipients:
+ alga |
2010-02-03 18:18:45 | alga | set | messageid: <1265221125.46.0.788083310396.issue7848@psf.upfronthosting.co.za> |
2010-02-03 18:18:43 | alga | link | issue7848 messages |
2010-02-03 18:18:43 | alga | create | |
|