pickle.load failing with ValueError: insecure string pickle

carroll at tjc.com carroll at tjc.com
Tue Feb 11 10:15:51 CET 2003


I forgot to include:


ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on
Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on
win32

On Tue, 11 Feb 2003 01:10:48 -0800, carroll at tjc.com wrote:

>I'm a relatively new Python user, using Pickle for the first time.
>pickle.load is dying with "ValueError: insecure string pickle"
>
>The object I'm trying to pickle is a fairly large (15,443 entries)
>dictionary of objects.  The objects are fairly straightforward -- all
>the attributes are relatively short strings.
>
>Here's my pickling/unpickling code (all together as a test case):
>
>======================================
>picklefile = "handict.pickle"
>print "dumping..."
>pickleout = open(picklefile,"w")
>pickle.dump(hanchars,pickleout)
>pickleout.close
>print "dumping done."
>hanchars={} #wipe out hanchars
>print "recovering..."
>picklein = open(picklefile, "r")
>hanchars = pickle.load(picklein)
>print "recovery done."
>======================================
>
>What I see:
>
>======================================
>dumping...
>dumping done.
>0
>recovering...
>Traceback (most recent call last):
>  File "test01.py", line 65, in ?
>    hanchars = pickle.load(picklein)
>  File "C:\Python22\lib\pickle.py", line 982, in load
>    return Unpickler(file).load()
>  File "C:\Python22\lib\pickle.py", line 597, in load
>    dispatch[key](self)
>  File "C:\Python22\lib\pickle.py", line 667, in load_string
>    raise ValueError, "insecure string pickle"
>ValueError: insecure string pickle
>======================================
>
>Ideas?
>
>I want to use pickle because my dictionary is derived from a 25-meg
>input file.  It's more efficient to just process it once and pickle
>the dictionary for future use.





More information about the Python-list mailing list