Message255434
| Author |
serhiy.storchaka |
| Recipients |
aronacher, eric.snow, georg.brandl, rhettinger, serhiy.storchaka |
| Date |
2015年11月26日.19:07:31 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1448564851.67.0.942668838013.issue4712@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The copy module uses the same __reduce__ protocol, but reconstruct the object in different order, first set state, then add items. This discrepancy causes a difference between results of pickle/unpickle and copy operations. Example:
>>> class L(list):
... def __getstate__(self):
... return list(self)
... def __setstate__(self, state):
... self[:] = state
...
>>> import copy, pickle
>>> pickle.loads(pickle.dumps(L([1, 2])))
[1, 2]
>>> copy.deepcopy(L([1, 2]))
[1, 2, 1, 2]
This was happened with xml.dom.minicompat.NodeList (issue10131).
Definitely one of pickle's or copy's behavior should be changed. But what? |
|