cPickle and HIGHEST_PROTOCOL problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Dahlbacka

    cPickle and HIGHEST_PROTOCOL problems

    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(fil e('myfile.pickl e','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(objec t):
    __slots__ = ['Name','Descrip tion']

    def __init__(self, Name=None, Description=Non e):
    self.Name = Name
    self.Descriptio n = Description
    def __getstate__(se lf):
    return {"Name":Name , "Description":D escription}
    def __setstate__(se lf, dict):
    Name = dict['Name']
    Description = dict['Description']
Working...