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.
Created on 2008年12月21日 17:24 by georg.brandl, last changed 2022年04月11日 14:56 by admin.
| Messages (4) | |||
|---|---|---|---|
| msg78154 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2008年12月21日 17:24 | |
When unpickling dict subclasses, the dict is filled via setitem before __setstate__ is called. This, and other behavior around subclasses of classes that have special pickle behavior should be documented. |
|||
| msg83098 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2009年03月03日 21:04 | |
The behavior is a PITA. It means that dict subclasses the redefine __setitem__ have unpleasant pickling challenges. The __setitem__ insertions are called before the subclass can initialize. The workaround involves a funky dance using __reduce__. See collections.OrderedDict::__reduce__() for an example. |
|||
| msg255434 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年11月26日 19:07 | |
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? |
|||
| msg255439 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2015年11月26日 22:09 | |
The order in copy was changed by issue1100562. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:43 | admin | set | github: 48962 |
| 2015年11月26日 22:11:25 | serhiy.storchaka | set | nosy:
+ pitrou, alexandre.vassalotti |
| 2015年11月26日 22:09:29 | serhiy.storchaka | set | messages: + msg255439 |
| 2015年11月26日 19:07:31 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg255434 versions: + Python 3.6 |
| 2014年04月02日 04:07:26 | eric.snow | set | nosy:
+ eric.snow versions: + Python 3.5, - Python 3.2, Python 3.3 |
| 2012年07月25日 22:53:49 | ezio.melotti | set | versions: + Python 3.2, Python 3.3, Python 3.4, - Python 2.6, Python 3.0, Python 3.1 |
| 2010年10月29日 10:07:21 | admin | set | assignee: georg.brandl -> docs@python |
| 2009年05月16日 22:56:32 | ajaksu2 | set | dependencies: + pickle.dumps cannot save instance of dict-derived class that overrides __getattribute__ |
| 2009年04月22日 14:39:15 | ajaksu2 | set | keywords: + easy |
| 2009年03月03日 21:04:39 | rhettinger | set | priority: low -> normal nosy: + rhettinger messages: + msg83098 |
| 2008年12月21日 17:24:04 | georg.brandl | create | |