[issue12680] cPickle.loads is not thread safe due to non-thread-safe imports
Antoine Pitrou
report at bugs.python.org
Fri Aug 5 12:50:46 CEST 2011
Antoine Pitrou <pitrou at free.fr> added the comment:
> PyImport_ExecCodeModuleEx adds the module to sys.modules *before*
> actually executing the code. This is a design flaw (can it really be
> changed? )
I guess it is done so to allow for circular imports.
> The second bug: in cPickle.c: func_class()
> cPickle 'manually' checks if a module is in sys.modules instead of
> letting the import mechanism do it for him (hence breaking the import
> lock's defense here).
I would guess it is an optimization shortcut. A solution (while keeping the optimization) would be to take the import lock before checking sys.modules.
Note that the _pickle module in 3.x has the same kind of logic, and therefore probably the same issue too (haven't tested).
----------
nosy: +pitrou
versions: +Python 3.2, Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12680>
_______________________________________
More information about the Python-bugs-list
mailing list