We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 20b14d9 commit 164423bCopy full SHA for 164423b
Python/import.c
@@ -4119,10 +4119,14 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate,
4119
4120
PyInterpreterState *interp = tstate->interp;
4121
4122
- PyObject *mod = PyImport_GetModule(abs_name);
4123
- if (mod != NULL) {
4124
- Py_DECREF(abs_name);
4125
- 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);
4126
+ if (mod != NULL) {
4127
+ Py_DECREF(abs_name);
4128
+ return mod;
4129
+ }
4130
}
4131
4132
// Check if the filter disables the lazy import
0 commit comments