Message53542
Last week I noticed that the pickle and cPickle modules
cannot handle bound methods. I found a solution that is
simple and (I think) general, so perhaps it should
become part of the standard library.
Here is my code:
import copy_reg
def pickle_bound_method(method):
return getattr, (method.im_self, method.__name__)
class _Foo:
def bar(self):
pass
_foo = _Foo()
copy_reg.constructor(getattr)
copy_reg.pickle(type(_foo.bar), pickle_bound_method)
|
|
Date |
User |
Action |
Args |
2007-08-23 16:02:13 | admin | link | issue558238 messages |
2007-08-23 16:02:13 | admin | create | |
|