Message8329
Logged In: YES
user_id=6380
Very interesting! Good analysis too (took me a while with
pdb to come to verify it :-). But neither class needs to
define __reduce__ -- the one they inherit from their bases,
type and object, will do the trick just as well.
The problem is that there are two things competing to be
newclass.__reduce__: on the one hand, the unbound method
__reduce__ of newclass instances; on the other hand, the
bound method __reduce__ of newclass, seen as a metaclass
instance. Unfortunately, the unbound method wins, but pickle
is expecting the bound method.
I've tried experimenting with a few ways of fixing this
(e.g. forcing pickle to get the bound __reduce__ method) but
there seem to be powerful forces preventing me from getting
this to work (and I don't mean just a screaming baby :-). I
think maybe the right solution is to make pickle realize
that newclass is a class, and prevent it from pickling it at
all -- it should just pickle a reference to it (i.e. the
module and class name) rather than attempting to pickle its
contents.
Stay tuned. |
|
Date |
User |
Action |
Args |
2007-08-23 13:58:10 | admin | link | issue494904 messages |
2007-08-23 13:58:10 | admin | create | |
|