pickle and __slots__

J

JL

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
 
J

John Nagle

JL said:
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
 
J

JL

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.
 
J

JL

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top