#15156: Pickling with __reduce__() loops creates invalid pickles
-------------------------------------+-------------------------------------
Reporter: vbraun | Owner:
Type: defect | Status: needs_info
Priority: major | Milestone: sage-6.3
Component: misc | Resolution:
Keywords: | Merged in:
Authors: SimonKing, | Reviewers:
jkeitel, novoselt, nbruin | Work issues:
Report Upstream: N/A | Commit:
Branch: | 82ba456b8c828700d28ac36822b300f00d8b1308
u/saraedum/ticket/15156 | Stopgaps:
Dependencies: #15692 |
-------------------------------------+-------------------------------------
Comment (by saraedum):
cPickle gets things wrong if any circularity is created in the first
parameter returned by `__reduce__`. Consider the following code, which
creates two objects which reference each other:
{{{
class A(object):
def __reduce__(self):
return A,(),{'b':self.b}
class B(object):
def __init__(self,a):
self.a = a
def __reduce__(self):
return B,(self.a,)
b=B(A())
b.a.b = b
}}}
With cPickle(pickle raises an assertion):
{{{
sage: b.a.b is b
True
sage: b = loads(dumps(b))
sage: b.a.b is b
False
}}}
This is in particular a problem with Homsets. The `__reduce__` of Hom
does:
{{{
return Hom, (self._domain, self._codomain, self.__category, False)
}}}
Often the domain or codomain reference back to the Homset somehow. I have
no idea how to fix this. The domain is really needed here because it
determines the class of the result and it is used for a lookup in a cache.
Any ideas?
--
Ticket URL: <http://trac.sagemath.org/ticket/15156#comment:14>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.