[Pythonmac-SIG] tricky cPickling

Etienne Antoniutti Di Muro etienne@alias.it
Wed, 16 Feb 2000 16:45:20 +0100


List members, hello there !!
recently I have encountered some problems using cPickle.load function.
Here it comes:
I do have two methods in a class (myclass.save(filename) and
myclass.load(filename)), each one is devoted to its obvious task, using
cPickle module.

myclass.save(filename) works properly, saving three cPickable objects,
say 'ss', 'pa' and 'rm'.Well, not quite simple ones, indeed (dumped file
is about 600K large)!!

myclass.load(filename) excepts some problems, as follows (note, it just
calls cPiclkle.load(file))!!! :-((

The firts Error encountered is a NameError with an object used by 'ss',
as if python is unable to load the module that object, comes from. Yes,
I know, I do explicitly import that module before loading 'ss' with
cPickle, but why   does cPickle not find that module on its own?

More Troublesome is that I have different behaviours of the Python
interpreter, according how i call the script that does the cPickle
loading action: I think this  is due to different exception management,
i.e:

1_ making my script an applet NO exception is raised;
2_ ruinning the script from the Python interactive window, it raises the
NameErroer exception mentioned above;
3 _the same script DOES NOT run from IDE menu File -> open ->
'myscript.py' -> "Run All"
4 _Most important, cause it is where i do really need it working, my
module does not work in a C function call, in which I embedded
myclass.load(filename) !!


At last but not at least i'm wondering why I get quite frequently
MemoryErrors running cPiclke methods.

thanks for support
etienne