mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Fix __lazy_modules__
This commit is contained in:
parent
b179da2cf5
commit
9078f571e4
1 changed files with 9 additions and 1 deletions
|
|
@ -4001,10 +4001,18 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
|
||||||
if (lazy_modules != NULL) {
|
if (lazy_modules != NULL) {
|
||||||
// Check and see if the module is opting in w/o syntax for backwards compatibility
|
// Check and see if the module is opting in w/o syntax for backwards compatibility
|
||||||
// with older Python versions.
|
// with older Python versions.
|
||||||
int contains = PySequence_Contains(lazy_modules, name);
|
int contains = PySequence_Contains(lazy_modules, abs_name);
|
||||||
if (contains < 0) {
|
if (contains < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
} else if (contains == 1) {
|
} else if (contains == 1) {
|
||||||
|
// Don't create lazy import if we're already resolving a lazy import
|
||||||
|
if (interp->imports.lazy_importing_modules != NULL &&
|
||||||
|
PySet_GET_SIZE(interp->imports.lazy_importing_modules) > 0) {
|
||||||
|
contains = 0; // Skip lazy import creation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contains == 1) {
|
||||||
_PyInterpreterFrame *frame = _PyEval_GetFrame();
|
_PyInterpreterFrame *frame = _PyEval_GetFrame();
|
||||||
if (frame == NULL) {
|
if (frame == NULL) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "no current frame");
|
PyErr_SetString(PyExc_RuntimeError, "no current frame");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue