#10353: ZODB is basically useless in Sage, since it uses pickle protocol 1
----------------------+-----------------------------------------------------
   Reporter:  was     |       Owner:  jason     
       Type:  defect  |      Status:  new       
   Priority:  major   |   Milestone:  sage-4.6.1
  Component:  misc    |    Keywords:            
     Author:          |    Upstream:  N/A       
   Reviewer:          |      Merged:            
Work_issues:          |  
----------------------+-----------------------------------------------------
 {{{
 wst...@sage:~$ /usr/local/bin/sage
 ----------------------------------------------------------------------
 | Sage Version 4.6, Release Date: 2010-10-30                         |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------
 sage: d = sage.databases.db.Database('sage_zodb', read_only=False)
 sage: d[12] = factor(12)
 sage: d.commit()
 ...
 TypeError: can't pickle SageObject objects
 }}}

 There is a zodb mailing list discussion related to the pickle protocol
 here:  http://www.mail-archive.com/[email protected]/msg04628.html

 In particular, pickle protocol 1 is hardcoded.  But SageObjects/Cython
 objects must use protocol 2 in many cases:
 {{{
 sage: import cPickle
 sage: F = factor(12)
 sage: cPickle.dumps(F, protocol=0)
 TypeError: can't pickle SageObject objects
 sage: cPickle.dumps(F, protocol=1)
 TypeError: can't pickle SageObject objects
 sage: cPickle.dumps(F, protocol=2)
 
'\x80\x02csage.structure.factorization\nFactorization\nq\x01)\x81q\x02}q\x03(U\x12_Factorization__crq\x04\x89U\x14_Factorization__unitq\x05csage.rings.integer\nmake_integer\nq\x06U\x011\x85Rq\x07U\x18_Factorization__universeq\x08csage.rings.integer_ring\nIntegerRing\nq\t)Rq\nU\x11_Factorization__xq\x0b]q\x0c(h\x06U\x012\x85Rq\rK\x02\x86q\x0eh\x06U\x013\x85Rq\x0fK\x01\x86q\x10eub.'
 }}}

 There is some code in Sage that uses ZODB (e.g, Cremona database), but I
 think it uses only pure python objects, so the above isn't a problem.

 See also the related ticket #10352.

 Some ideas for how to fix this:

   - Modify ZODB itself, e.g., by changing: ZODB.serialiize.ObjectWriter as
 suggested here: http://www.mail-archive.com/zodb-
 [email protected]/msg04766.html

   - Figure out how to monkeypatch ODB.serialiize.ObjectWriter at runtime,
 then document this hack

   - "Fix" SageObject and/or Cython, so Sage objects can serialize using
 Pickle protocol 1 instead of requiring 2.  I don't personally understand
 exactly why SageObject can't be pickled using protocol 1.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10353>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

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

Reply via email to