[issue10701] Error pickling a dict
Alexandre Vassalotti added the comment: The mutating __getstate__ is very likely the problem here. I've attached a small test case which shows the described behavior. We could fix this by always making a copy of any mutable container we want to iterate over to save its items. Performance-wise this solution is not very attractive. We are better off documenting this behavior as a limitation of __getstate__. -- Added file: http://bugs.python.org/file29843/issue10701.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10701] Error pickling a dict
Charles-François Natali added the comment: It's interesting. The example behaves unstable on 3.3+ with C implementation of picle, sometimes works, sometimes fails. With Python implementation and on 3.2 it works always. On 2.7 it fails always. That's hash randomization. -- nosy: +neologix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10701] Error pickling a dict
Serhiy Storchaka added the comment: It's interesting. The example behaves unstable on 3.3+ with C implementation of picle, sometimes works, sometimes fails. With Python implementation and on 3.2 it works always. On 2.7 it fails always. A difference between C and Python implementations of pickle is a bug and should be fixed. -- nosy: +alexandre.vassalotti, pitrou, serhiy.storchaka versions: +Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10701] Error pickling a dict
Antoine Pitrou added the comment: I find the posted code mystifying. As the name suggests, __getstate__ should probably not mutate anything. It would be nice if you could post a simpler example to reproduce issue. Even better if it doesn't have a mutating __getstate__, I would say. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10701] Error pickling a dict
New submission from Alexander Belopolsky belopol...@users.sourceforge.net: The work-around that I proposed for issue10700 does not work with Python 2.x: $ python2.7 dict-graph.py Vertex 0 - 2, 1 Vertex 1 - Vertex 2 - Traceback (most recent call last): File dict-graph.py, line 74, in module p = pickle.dumps(g) ... File .../Lib/pickle.py, line 661, in _batch_setitems for k, v in items: RuntimeError: dictionary changed size during iteration -- files: dict-graph.py messages: 123948 nosy: Leo.Na, belopolsky priority: normal severity: normal stage: needs patch status: open title: Error pickling a dict type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file20038/dict-graph.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10701 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com