Skip to content

Commit 9078f57

Browse files
pablogsalDinoV
authored andcommitted
Fix __lazy_modules__
1 parent b179da2 commit 9078f57

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Python/import.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4001,10 +4001,18 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
40014001
if (lazy_modules != NULL) {
40024002
// Check and see if the module is opting in w/o syntax for backwards compatibility
40034003
// with older Python versions.
4004-
int contains = PySequence_Contains(lazy_modules, name);
4004+
int contains = PySequence_Contains(lazy_modules, abs_name);
40054005
if (contains < 0) {
40064006
goto error;
40074007
} else if (contains == 1) {
4008+
// Don't create lazy import if we're already resolving a lazy import
4009+
if (interp->imports.lazy_importing_modules != NULL &&
4010+
PySet_GET_SIZE(interp->imports.lazy_importing_modules) > 0) {
4011+
contains = 0; // Skip lazy import creation
4012+
}
4013+
}
4014+
4015+
if (contains == 1) {
40084016
_PyInterpreterFrame *frame = _PyEval_GetFrame();
40094017
if (frame == NULL) {
40104018
PyErr_SetString(PyExc_RuntimeError, "no current frame");

0 commit comments

Comments
 (0)