summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-08-27 22:24:52 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-08-27 22:24:52 (GMT)
commit0398985920dcad1fcff0859e18a5911a6c685ff1 (patch)
treede0d47e15582579bb02517e08759d9bba3619890 /Python/import.c
parent30147710e8d6b2b5aebcf6f774fe289a4918958c (diff)
downloadcpython-0398985920dcad1fcff0859e18a5911a6c685ff1.zip
cpython-0398985920dcad1fcff0859e18a5911a6c685ff1.tar.gz
cpython-0398985920dcad1fcff0859e18a5911a6c685ff1.tar.bz2
Issue #15781: Fix two small race conditions in import's module locking.
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/import.c b/Python/import.c
index 2540f9d..2f71b97 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();