mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
bpo-30891: Fix importlib _find_and_load() race condition (#2646)
* Rewrite importlib _get_module_lock(): it is now responsible to hold the imp lock directly. * _find_and_load() now holds the module lock to check if name is in sys.modules to prevent a race condition
This commit is contained in:
parent
b136f11f3a
commit
4f9a446f3f
3 changed files with 1557 additions and 1568 deletions
|
@ -1559,10 +1559,6 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
|
|||
if (initializing == -1)
|
||||
PyErr_Clear();
|
||||
if (initializing > 0) {
|
||||
#ifdef WITH_THREAD
|
||||
_PyImport_AcquireLock();
|
||||
#endif
|
||||
/* _bootstrap._lock_unlock_module() releases the import lock */
|
||||
value = _PyObject_CallMethodIdObjArgs(interp->importlib,
|
||||
&PyId__lock_unlock_module, abs_name,
|
||||
NULL);
|
||||
|
|
3063
Python/importlib.h
3063
Python/importlib.h
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue