Message255434
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? |
|
| Date |
User |
Action |
Args |
| 2015-11-26 19:07:31 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, georg.brandl, rhettinger, aronacher, eric.snow |
| 2015-11-26 19:07:31 | serhiy.storchaka | set | messageid: <[email protected]> |
| 2015-11-26 19:07:31 | serhiy.storchaka | link | issue4712 messages |
| 2015-11-26 19:07:31 | serhiy.storchaka | create | |
|