cPickle and HIGHEST_PROTOCOL problems

Simon Dahlbacka sdahlbac at abo.fi
Tue Feb 24 08:16:58 EST 2004


I'm trying to cache some information using cPickle
and I thought that using cPickle.HIGHEST_PROTOCOL would give me an
efficient representation.

However,

when trying to load the information back I just keep getting a broken
pickle with EOF error from cPicle.load(file('myfile.pickle','r'))

if I am not using cPickle.HIGHEST_PROTOCOL  or -1 or 2 it seems to
work nicely, is this a bug or something else?  (python 2.3.2 on winxp)

the information to be pickled is a dictionary of  some strings and a
list of custom objects defined as:

class ErrorCode(object):
    __slots__ = ['Name','Description']

    def __init__(self, Name=None, Description=None):
        self.Name = Name
        self.Description = Description
    def __getstate__(self):
        return {"Name":Name, "Description":Description}
    def __setstate__(self, dict):
        Name = dict['Name']
        Description = dict['Description']



More information about the Python-list mailing list