[issue558238] Pickling bound methods

Antoine Pitrou report at bugs.python.org
Fri Jul 16 21:26:53 CEST 2010

Antoine Pitrou <pitrou at free.fr> added the comment:

See also issue3657. For some reasons, C bound methods aliased as module globals can be pickled, but not similarly aliased Python bound methods:

>>> random.random, random.seed
(<built-in method random of Random object at 0x27abe20>, <bound method Random.seed of <random.Random object at 0x27abe20>>)
>>> pickle.dumps(random.random)
>>> pickle.dumps(random.seed)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/antoine/py3k/__svn__/Lib/pickle.py", line 1314, in dumps
    Pickler(f, protocol, fix_imports=fix_imports).dump(obj)
_pickle.PicklingError: Can't pickle <class 'method'>: attribute lookup builtins.method failed

assignee: loewis -> 
nosy: +belopolsky, pitrou
stage:  -> needs patch
versions: +Python 3.2

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list