Sagiv Malihi <sagivmal...@gmail.com> added the comment:

OK, digging deeper reveals that there are actually two bugs here, one is 
conceptual in the python importing mechanism, and the other is technical in 
cPickle.

The first bug: 
PyImport_ExecCodeModuleEx adds the module to sys.modules *before* actually 
executing the code. This is a design flaw (can it really be changed? )
Demonstrating this bug is easy using the foo.py module from the previous 
comment:

def f():
    if 'bla' in sys.modules:
        bla = sys.modules['bla']
    else:
        import bla
    return bla.A()
running two instances of f in two threads results in the same error.

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).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12680>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to