Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 78779:7fa6336e9864
Issue #15781: Fix two small race conditions in import's module locking.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Tue, 28 Aug 2012 00:24:52 +0200 |
| parents | b878df1d23b1 |
| children | 3f6db10b7a69 |
line wrap: on
line diff
--- a/Python/import.c Mon Aug 27 20:27:51 2012 +0300 +++ b/Python/import.c Tue Aug 28 00:24:52 2012 +0200 @@ -1408,7 +1408,11 @@ 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();
