Hello,
When I am using Sage from the command line on my own PC (SageMath version 
7.2, Release Date: 2016-05-15) I can do:

sage:  class myint(SageObject):
....:         def __init__(self, n):
....:                 self.value = n
....:         
sage: p = myint(3)
sage: save(p,'p')
sage: q = load('p')
sage: print q.value
3
sage: help(p)
Help on myint in module __main__ object:

class myint(sage.structure.sage_object.SageObject)
 |  Method resolution order:
 |      myint
 |      sage.structure.sage_object.SageObject
 |      __builtin__.object
...

If I try to do the same in a SageMathCloud worksheet: 
https://cloud.sagemath.com/projects/80f4c9e7-8a37-4f59-82e7-aa179ec0b652/files/public/save_bug_example.sagews
I see:

class myint(SageObject):
    def __init__(self, n):
       self.value = n

p = myint(3)
save(p,'p')
---

Error in lines 5-5
Traceback (most recent call last):
  File 
"/projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_server.py",
 line 957, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
  File "sage/structure/sage_object.pyx", line 1076, in 
sage.structure.sage_object.save 
(/projects/sage/sage-7.3/src/build/cythonized/sage/structure/sage_object.c:11864)
    obj.save(filename=filename, compress=compress, **kwds)
  File "sage/structure/sage_object.pyx", line 439, in 
sage.structure.sage_object.SageObject.save 
(/projects/sage/sage-7.3/src/build/cythonized/sage/structure/sage_object.c:3410)
    open(filename, 'wb').write(self.dumps(compress))
  File "sage/structure/sage_object.pyx", line 463, in 
sage.structure.sage_object.SageObject.dumps 
(/projects/sage/sage-7.3/src/build/cythonized/sage/structure/sage_object.c:3701)
    s = cPickle.dumps(self, protocol=2)
PicklingError: Can't pickle <class 'myint'>: attribute lookup __builtin__.myint 
failed

---
help(p)
---

Help on myint in module __builtin__ object:

class myint(sage.structure.sage_object.SageObject)
 |  Method resolution order:
 |      myint
 |      sage.structure.sage_object.SageObject
 |      object
 |  

Why are the module and the method resolution order different between Sage 
and SageMathCloud worksheet?

In a SageMathCloud worksheet, how do I save an instance of a user defined 
class?

All the best, Paul

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to