tricky cPickling

Etienne Antoniutti Di Muro etienne at
Thu Feb 17 18:59:43 CET 2000

This is my first message posted, so hi everybody !! :-)

Recently I have experienced some problems using cPickle.load function.
Here it comes:
code is pretty simple:

class MyStuff:
        def save(filename):
                obj = (GlobalVar1, GlobalVar2, GlobalVar3) #GlobalVar
are instances of classes
                f = open(filename, "w")
                cPickle.dump(f, obj)

   def load(filename):
           f = open(filename, "r")
          (globalVar1, globalVar2, globalVar3) = cPickle.load(f)
          return obj

I experiece errors in unpickling only (MyStuff.load("MyFileName")), they
are listed as follows:

1_ NameErrors of some objects from modules used by the "GlobalVar"
cPickled. (but please note that those modules are properly imported
before cPickling);

2_ MemoryErrors in cPickling;

3_ Different behaviours (raised exceptions) of the script which uses
MyStuff.load("MyFileName") method, according how i call it. Is it due to
different exception managment of MacPython IDE instead of MacPython
AppletBuilder ??

4_ Cause of those errors I can't embed MyClass in a C function, that is
where i need it to work.

Any Suggestion ??

Thanks for support

More information about the Python-list mailing list