[issue3657] pickle can pickle the wrong function
Tim Peters
report at bugs.python.org
Sat Sep 13 06:14:47 CEST 2008
Tim Peters <tim.peters at gmail.com> added the comment:
BTW, note that the Title of this issue is misleading:
pickle.whichmodule() uses object identity ("is":
if ... getattr(module, funcname, None) is func:
) to determine whether the given function object is supplied by a
module, so it's /not/ the case that a "wrong" function can be pickled.
The worst that can happen is that the correct function is pickled but
obtained from a possibly surprising module. For example, random.random
can't be confused with any other function named "random".
I expect this is why nobody has ever complained about it: unless you're
looking at the strings embedded in the pickle GLOBAL opcode, it's
unlikely to have a visible consequence.
It would still be nice if pickle could identify "the most natural"
module for a given function, but hard to make a case that doing so would
be much more than /just/ "nice".
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3657>
_______________________________________
More information about the Python-bugs-list
mailing list