By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,598 Members | 1,498 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,598 IT Pros & Developers. It's quick & easy.

cannot pickle object returned by urllib2.urlopen()

P: n/a
got a exception: "a class that defines __slots__ without defining
__getstate__ cannot be pickled "
why?
and is there any other dump method but for pickle to store the kind of
object ?

Nov 12 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Wed, 12 Nov 2008 11:00:26 +0800, scsoce wrote:
got a exception: "a class that defines __slots__ without defining
__getstate__ cannot be pickled "
why?
and is there any other dump method but for pickle to store the kind of
object ?
I can't answer either of your questions, but why are you trying to pickle
an open connection to a (possibly remote) URL? I can't imagine how that
could possibly work even in principle.

--
Steven
Nov 12 '08 #2

P: n/a
On Wed, 12 Nov 2008 11:00:26 +0800, scsoce wrote:
>
>>got a exception: "a class that defines __slots__ without defining
__getstate__ cannot be pickled "
why?
Because in the absence of any other information, the default
way of pickling an object is to save the contents of its
__dict__. But an object with __slots__ doesn't necessarily
have a __dict__, and even if it does, it doesn't include
the contents of the slots. So you need to tell pickle how to
deal with it by defining __getstate__ and __setstate__ methods.

--
Greg
Nov 13 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.