#5986: [with patch, needs review] Workaround mishandled nested classes in Python
and cPickle
---------------------+------------------------------------------------------
Reporter: nthiery | Owner: nthiery
Type: defect | Status: new
Priority: major | Milestone: sage-4.0
Component: misc | Keywords: pickling, nested classes
---------------------+------------------------------------------------------
With the python code below::
class A:
class B:
pass
Python 2.6 erroneously set the 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)
Depends on #5483 and #5985
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5986>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
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-trac?hl=en
-~----------~----~----~----~------~----~------~--~---