On Tue, May 05, 2009 at 06:48:06AM -0700, William Stein wrote:
> 
> 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?

Not yet but this of course definitely is the plan.

(sorry, I already have trouble keeping up with my current average
patch submission of one per day).

> This patch will definitely not go into Sage unless it will
> definitely go into Python at some point in the future.  

What a nice way to start a polite negotiation between gentlemens.

(european vs american culture strikes back :-) )

> 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.

(1) Yes, maybe my assumption is wrong, though I strongly doubt it. In
any cases, what is for sure is that with the current version of
Python, nested classes cannot be pickled. And this is undoubtly a bug
(or missing feature if you prefer). The single purpose of my patch is
to fix this. Any other fix or workaround will do as well, and is more
than welcome.

(2) My patch does not touch the Python interpreter, but a copy of
cPickle within the Sage source tree. This does not prevent upgrading
python, as long as we keep our copy of cPickle reasonably updated. Of
course this is only acceptable as a temporary workaround.

(3) -1 on holding back further a large scale merge for a minor
technical detail that will eventually be resolved one way or the
other.

(4) My general feeling is that nested classes in Python are on the
edge of full maturity, with just a couple glitches here and
there. Typically, Florent mentionned to me that the devel version of
Sphynx now handled them correctly. This is why I feel confident using
them. And there is a clear advantage to using them (which I'll argue
about in my demo in Seattle).

Best,
                                Nicolas
--
Nicolas M. Thiéry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to