summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-07-06 05:09:03 (GMT)
committerGitHub <noreply@github.com>2017-07-06 05:09:03 (GMT)
commitb4baacee1adc06edbe30ac7574d17a8cd168e2e0 (patch)
treea01eb344f832a876239e6a7dd33806f5945206c2 /Python/import.c
parent1ccbad9c95cf5782a1329eeaecba6e3eb0c37cb8 (diff)
downloadcpython-b4baacee1adc06edbe30ac7574d17a8cd168e2e0.zip
cpython-b4baacee1adc06edbe30ac7574d17a8cd168e2e0.tar.gz
cpython-b4baacee1adc06edbe30ac7574d17a8cd168e2e0.tar.bz2
bpo-30814: Fixed a race condition when import a submodule from a package. (#2580)
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c17
1 files changed, 1 insertions, 16 deletions
diff --git a/Python/import.c b/Python/import.c
index d8a207b..6cdb366 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1532,18 +1532,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
}
mod = PyDict_GetItem(interp->modules, abs_name);
- if (mod == Py_None) {
- PyObject *msg = PyUnicode_FromFormat("import of %R halted; "
- "None in sys.modules", abs_name);
- if (msg != NULL) {
- PyErr_SetImportErrorSubclass(PyExc_ModuleNotFoundError, msg,
- abs_name, NULL);
- Py_DECREF(msg);
- }
- mod = NULL;
- goto error;
- }
- else if (mod != NULL) {
+ if (mod != NULL && mod != Py_None) {
_Py_IDENTIFIER(__spec__);
_Py_IDENTIFIER(_initializing);
_Py_IDENTIFIER(_lock_unlock_module);
@@ -1584,10 +1573,6 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
}
}
else {
-#ifdef WITH_THREAD
- _PyImport_AcquireLock();
-#endif
- /* _bootstrap._find_and_load() releases the import lock */
mod = _PyObject_CallMethodIdObjArgs(interp->importlib,
&PyId__find_and_load, abs_name,
interp->import_func, NULL);