Serhiy Storchaka added the comment: 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? ---------- nosy: +serhiy.storchaka versions: +Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4712> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com