diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-28 00:24:52 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-28 00:24:52 +0200 |
commit | 4f0338cab745c8678df4113f2fcd38dd234a73f8 (patch) | |
tree | 9e8d59aa1480b43eb818f2510d2c105500b99960 /Python/import.c | |
parent | 79dbded0fae7c1c10454a391ae3ebbb39c5b7a0f (diff) | |
download | cpython-git-4f0338cab745c8678df4113f2fcd38dd234a73f8.tar.gz |
Issue #15781: Fix two small race conditions in import's module locking.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/import.c b/Python/import.c index 2540f9d7b7..2f71b97bc8 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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(); |