durusmail: durus-users: Can't pickle
Can't pickle
2005-02-06
Can't pickle
Neil Schemenauer
2005-02-06
On Sat, Feb 05, 2005 at 06:27:59PM -0800, Michael Watkins wrote:
>     self.pickler.dump(obj.__getstate__())
> cPickle.PicklingError: Can't pickle : attribute
> lookup __builtin__.instancemethod failed

It looks like there is an 'instancemethod' object in an instances
__dict__.  One way to do that:

    class A:
        pass

    class B:
        def method(self):
            pass

    a = A()
    a.method = B.method

Solutions are: a) don't do that, b) use a __getstate__ and
__setstate__ that removes it from __dict__ and adds it back
again.

  Neil

reply