Insecure string pickle?

Thomas Wouters thomas at xs4all.net
Mon Feb 7 17:34:59 CET 2000


On Mon, Feb 07, 2000 at 10:27:38AM -0500, Gaetan Corneau wrote:

> I have put objects (magazine routing lists) in a shelf. I can list all the
> keys, and I can load all objects except one. 
> When I try to load a particular list (using it's name), I get the following
> error message:
> ValueError: insecure string pickle
> What does that mean?

Well, it is impossible to tell for sure without knowing the name of the
particular list and it's contents, but something goes wrong with the
unpickling of the data. cPickle is slightly picky about which strings it
unpickles, it refuses to load strings that look fishy. Apparently, part of
the stored data looks weird, to cPickle, perhaps due to a strange amount of
backslashes, quotes or otherwise weird characters -- i've never seen this
myself.

You can try to circumvent it by using pickle instead of cPickle... You'll
either have to edit the shelve.py module, though, or do something this:

<first part of your code, until 'import shelve'>
import shelve
import pickle
shelve.Pickler = pickle.Pickler
shelve.Unpickler = pickle.Unpickler
<rest of your code>

The placing of the added code is irrelevant as long as you place your code
between the import of shelve and the actual usuage of shelve.

The problem could also just be that your shelve is broken. Some pieces fell
off, and the parts that are left are too weird to decode... It depends on
what was stored in it.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list