Dear Carl, dear all,
This is a call for comments and reviews for the new ticket #5986 whose
description is:
------------------------------------------------------------------------------
With the python code below::
class A:
class B:
pass
Python 2.6 erroneously set B.__name__ to "B" instead of "A.B".
Furthermore, upon pickling (here in save_global) *and* unpickling (in
load_global) a class with name "A.B" in a module mod, the standard
cPickle module searches for "A.B" in mod.dict instead of looking up
"A" and then "B" in the result.
This patch works around this by a patch to cPickle.c which fixes the
name for B to its appropriate value A.B, and inserts 'A.B' = A.B in
mod.dict (hacky, but seems to work) the first time A.B is pickled, and
fixes load_global to implement a proper lookup upon unpickling.
It also ensures that sage/interfaces/sage0.py uses loads/dumps from
sage_object rather than calling directly cPickle.loads/dumps
(+1 by cwitty on this change)
Python source experts are more than welcome to rework/rewrite this
patch!
Depends on #5483 (explain-pickle) and #5985
------------------------------------------------------------------------------
Thanks in advance!
Best,
Nicolas
On Fri, Mar 13, 2009 at 01:26:11PM -0700, Carl Witty wrote:
...
> > Well, that's a bug in python that should eventually be fixed in
> > python. But yeah, your workaround could be a good way out.
>
> I certainly wouldn't call it a bug -- at the most, a missing feature.
> I'm not even convinced that a patched version would be an improvement.
> (For one thing, you would need to also patch the unpickle side, which
> means that you can't write a pickle using your patch and read it in
> older versions of Python. We don't care much about that in Sage, but
> I think it's important to the Python people.)
Well, you can't pickle/unpickle it in the first place, so this can't
hurt more than currently.
--
Nicolas M. ThiƩry "Isil" <[email protected]>
http://Nicolas.Thiery.name/
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---