On Wednesday, September 4, 2013 4:29:30 PM UTC-7, Volker Braun wrote:
>
> Having spent a day to look closer at pickling issues, there seem to be 
> some dangerous issues. In particular, Python currently has a bug where you 
> can create pickles that unpickle incorrectly without raising any exceptions 
> (http://trac.sagemath.org/15156).
>

OK, the problem were two sage classes, CachedFunction and Map, which tried 
to pickle caches and dictionaries (containing caches!) as part of the 
construction step. Since those can easily contain circular references, 
that's not a good idea. The solution is  to move their initialization to 
the setstate phase.

Of course, this only resolves the circularity part of the problems. Objects 
that end up unpickling badly because *too much* of their state is deferred 
to setstate need their `reduce` methods adjusted in the opposite direction.

Note that while Python has hooks such as __getinitargs__ and __getnewargs__ 
to customize reduction behaviour, most sage code seems to prefer to roll 
its own methods via custom __reduce__ methods. This gives better control 
but makes it easier to err in the direction of trying to do too much at 
construction time.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to