On Tue, May 5, 2009 at 12:30 AM, Nicolas M. Thiery <nicolas.thi...@u-psud.fr> wrote: > > 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.
Have you posted this to the python-dev mailing list? This patch will definitely not go into Sage unless it will definitely go into Python at some point in the future. What if you are simply wrong in your assertion that Python "erroneously set B.__name__ to "B" instead of "A.B"?" Then you'll just be making it so Sage can never work with any unpatched version of Python. Note that (1) in the entire history of the Sage project, we have never once patched the Python interpreter, except to fix small bus we found whose fixes were upstreamed (the only thing I can think of along those lines is a readline bug on Itanium), and (2) if we patch Python, then Sage for Debian/Ubuntu will never be upgraded to the version of Sage with this patch until the patch is upstreamed into Python. > > 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" <nthi...@users.sf.net> > http://Nicolas.Thiery.name/ > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---