Issue #15781: Fix two small race conditions in import's module locking.

This commit is contained in:
Antoine Pitrou 2012-08-28 00:24:52 +02:00
parent 30147710e8
commit 0398985920
5 changed files with 3679 additions and 3655 deletions

View file

@ -1408,7 +1408,11 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals,
int initializing = 0;
Py_INCREF(mod);
/* Only call _bootstrap._lock_unlock_module() if __initializing__ is true. */
/* Optimization: only call _bootstrap._lock_unlock_module() if
__initializing__ is true.
NOTE: because of this, __initializing__ must be set *before*
stuffing the new module in sys.modules.
*/
value = _PyObject_GetAttrId(mod, &PyId___initializing__);
if (value == NULL)
PyErr_Clear();

File diff suppressed because it is too large Load diff