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 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 <>
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:31serhiy.storchakasetrecipients: + serhiy.storchaka, georg.brandl, rhettinger, aronacher, eric.snow
2015-11-26 19:07:31serhiy.storchakasetmessageid: <>
2015-11-26 19:07:31serhiy.storchakalinkissue4712 messages
2015-11-26 19:07:31serhiy.storchakacreate