pickle and __slots__ - Python
This is a discussion on pickle and __slots__ - Python ; Hello,
I am trying to pickle an object, and I get:
TypeError: a class that defines __slots__ without defining
__getstate__ cannot be pickled
I didn't find __slots__ in the object or the class. Is there a way to
find it, ...
-
pickle and __slots__
Hello,
I am trying to pickle an object, and I get:
TypeError: a class that defines __slots__ without defining
__getstate__ cannot be pickled
I didn't find __slots__ in the object or the class. Is there a way to
find it, or to to know which object or class causes the problem?
Thanks
-
Re: pickle and __slots__
JL wrote:
> Hello,
>
> I am trying to pickle an object, and I get:
>
> TypeError: a class that defines __slots__ without defining
> __getstate__ cannot be pickled
>
> I didn't find __slots__ in the object or the class. Is there a way to
> find it, or to to know which object or class causes the problem?
>
> Thanks
>
Is this a subclass? Look at the parent classes.
John Nagle
-
Re: pickle and __slots__
> Is this a subclass? Look at the parent classes.
Its class is a subclass of a similar class, but it indirectly
references instances of subclasses of asyncore.dispatcher or
asynchat.async_chat. I don't think there are other particular classes.
If I remove the first references, pickle works. Anyway it seems that I
will have to mask the asyncore.dispatcher and asynchat.async_chat
subclass instances which will not be relevant at unpickle time.
-
Re: pickle and __slots__
I added the following method to the 2 subclasses of
asyncore.dispatcher and asynchat.async_chat and now pickle works:
def __getstate__(self):
return
Later I will probably modify this method so it returns something more
interesting.
Thanks for your help! I was confused because I am not sure what can be
pickled or not.
Similar Threads
-
By Application Development in forum Python
Replies: 15
Last Post: 11-02-2007, 02:36 PM
-
By Application Development in forum Python
Replies: 0
Last Post: 11-01-2007, 04:34 PM
-
By Application Development in forum Python
Replies: 0
Last Post: 11-01-2007, 03:59 PM
-
By Application Development in forum Python
Replies: 2
Last Post: 09-11-2007, 01:51 PM
-
By Application Development in forum Python
Replies: 1
Last Post: 07-07-2007, 12:59 PM