This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hinsen
Recipients
Date 2002-05-20.11:17:41
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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)

History
Date User Action Args
2007-08-23 16:02:13adminlinkissue558238 messages
2007-08-23 16:02:13admincreate