Message73081
The explanation is actually simple, do not blame bsddb :-)
random.random is a built-in method, so its __module__ attribute is not
set. To find it, pickle.whichmodule loops through all sys.modules, and
pick the first one that contains the function.
I reproduced the problem with a simple file:
# someModule.py
from random import random
then, start python and:
>>> import someModule, random, pickle
>>> pickle.dumps(random.random, 0)
'csomeModule\nrandom\np0\n.'
You may have to change the name of "someModule", to be sure that it
appears before "random" in sys.modules. Tested on Windows and x86_64 Linux.
To correct this, one direction would be to search only built-in or
extension modules; for bound methods (random.random.__self__ is not
None), try to dump separately the instance and the method name (but
getattr(random._inst, 'random') is not random.random).
Or simply change the test... |
|
Date |
User |
Action |
Args |
2008-09-12 11:35:52 | amaury.forgeotdarc | set | recipients:
+ amaury.forgeotdarc, barry, nnorwitz, benjamin.peterson |
2008-09-12 11:35:52 | amaury.forgeotdarc | set | messageid: <1221219352.51.0.256963452875.issue3657@psf.upfronthosting.co.za> |
2008-09-12 11:34:58 | amaury.forgeotdarc | link | issue3657 messages |
2008-09-12 11:34:57 | amaury.forgeotdarc | create | |
|