mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Implement disabling imports in try/except and * imports, report errors on bad usage of lazy
This commit is contained in:
parent
164423b42b
commit
00e7800e4c
11 changed files with 99 additions and 27 deletions
|
|
@ -4118,16 +4118,8 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate,
|
|||
}
|
||||
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
_PyInterpreterFrame *frame = _PyEval_GetFrame();
|
||||
assert(frame->f_globals == frame->f_locals); // should only be called in global scope
|
||||
|
||||
// Check if the filter disables the lazy import
|
||||
PyObject *filter = LAZY_IMPORTS_FILTER(interp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue