[issue1062277] Pickle breakage with reduction of recursive structures

Alexander Belopolsky report at bugs.python.org
Sun Jun 29 22:25:17 CEST 2014


Alexander Belopolsky added the comment:

Problem "B" has been resolved, but problem "A" is still there.

Python 3.4.1 (default, Jun 29 2014, 15:26:46)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class C:
...     def __init__(self, x=None):
...         self.x = x if x is not None else self
...     def __reduce__(self):
...         return C, (self.x,)
...
>>> import pickle
>>> pickle.dumps(C())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: maximum recursion depth exceeded while calling a Python object
>>> c = C([])
>>> c.x.append(c)
>>> c.x[0] is c
True
>>> c2 = pickle.loads(pickle.dumps(c))
>>> c2.x[0] is c2
True

----------
assignee: belopolsky -> 
versions: +Python 3.5 -Python 2.7, Python 3.2, Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1062277>
_______________________________________


More information about the Python-bugs-list mailing list