cPickle from 2.2 to 2.1

paul paul.koelle at archit.uni-weimar.de
Mon Dec 15 06:25:46 EST 2003


Tim Peters wrote:
> [paul]
> 
>>I use cPickle in a small .cgi to save data. It run's fine on python
>>2.2.3 (used for development) but fails on 2.1.1 (webserver) with:
>>
>>   File "spyblog.py", line 543, in __init__
>>     self.entry = cPickle.load(open(log + self.filename, 'r+'))
>>SystemError: Failed to import class _reconstructor from module
>>copy_reg
[ --snipp-- ]

> IOW, if you want to read current pickles under older Pythons, you have to
> avoid pickling anything of a type that didn't exist in the older Pythons.
> For another example, you can't expect a pickle of a Unicode string to get
> unpickled under Python 1.5.2 either (since Unicode strings didn't exist in
> 1.5.2).


Thanks for pointing that out (seems rather obvious now ;). I thought
pickle is a fast and convenient method to store/restore data. Now I see 
the drawbacks.

BTW: It was a hack to avoid the xml.dom.minidom/unicode/non ASCII 
charset/codec/writer mess. Seems like I have to look at that once more.

greetings
  Paul






More information about the Python-list mailing list