Message98793
| 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: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 |
|