Python Pickling Issue

Brandon Harris brandon.harris at reelfx.com
Thu Nov 3 10:58:51 EDT 2011


After digging around a while I discovered I was attempting to pickle a 
third party class that can't be pickled. Initially I was removing it 
before pickling and everything was kosher, but at some point it got back 
onto the class. Apologies.

Brandon L. Harris


On 11/03/2011 09:42 AM, Brandon Harris wrote:
> I have written a fairly large DAG with python and I've run into an 
> issue when attempting to pickle the data to disk.
> It will pickle fine the first time, but if I call pickle again, it 
> throws this error.
>
> /usr/lib64/python2.6/copy_reg.py in _reduce_ex(self, proto)
>      68     else:
>      69         if base is self.__class__:
> ---> 70             raise TypeError, "can't pickle %s objects" % 
> base.__name__
>      71         state = base(self)
>      72     args = (self.__class__, base, state)
>
> TypeError: can't pickle function objects
>
> I'm calling
> save_file = open('my_file.rsf', 'w')
> cPickle.dump(self, save_file)
>
> I have attempted to pickle the object to a different file after the 
> first time, but the error is still thrown.
>
> This wouldn't be very hard to track down if the error gave any 
> indication as to where or what this function it can't pickle is, so
> if there's any possible way to at least get the name of what's failing 
> to be pickled, that would be a win.
>
> Thanks in advance for all replies.
>
> Brandon L. Harris
>




More information about the Python-list mailing list