mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Fix submodules crash
This commit is contained in:
parent
20b14d9ca4
commit
164423b42b
1 changed files with 8 additions and 4 deletions
|
|
@ -4119,10 +4119,14 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate,
|
|||
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
|
||||
PyObject *mod = PyImport_GetModule(abs_name);
|
||||
if (mod != NULL) {
|
||||
Py_DECREF(abs_name);
|
||||
return mod;
|
||||
// Don't return early if we have a fromlist - we need to handle the import properly
|
||||
// to ensure submodules are loaded
|
||||
if (fromlist == NULL || fromlist == Py_None) {
|
||||
PyObject *mod = PyImport_GetModule(abs_name);
|
||||
if (mod != NULL) {
|
||||
Py_DECREF(abs_name);
|
||||
return mod;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the filter disables the lazy import
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue