471,354 Members | 1,505 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

pickle and __slots__

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

Oct 4 '07 #1
3 4462
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
Oct 4 '07 #2
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.

Oct 4 '07 #3
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.

Oct 4 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gonçalo Rodrigues | last post: by
16 posts views Thread by Nicolas Fleury | last post: by
4 posts views Thread by Christos TZOTZIOY Georgiou | last post: by
8 posts views Thread by Hans Georg Krauthaeuser | last post: by
1 post views Thread by i_hate | last post: by
3 posts views Thread by dgdev | last post: by
27 posts views Thread by Licheng Fang | last post: by
10 posts views Thread by krustymonkey | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.