gh-146369: Ensure PYTHON_LAZY_IMPORTS=none overrides __lazy_modules__ (#146371)

This commit is contained in:
Hugo van Kemenade 2026-03-25 13:08:45 +02:00 committed by GitHub
parent 2be147e1e7
commit d0e66ef1c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 1 deletions

View file

@ -3086,7 +3086,7 @@ _PyEval_LazyImportName(PyThreadState *tstate, PyObject *builtins,
break;
}
if (!lazy) {
if (!lazy && PyImport_GetLazyImportsMode() != PyImport_LAZY_NONE) {
// See if __lazy_modules__ forces this to be lazy.
lazy = check_lazy_import_compatibility(tstate, globals, name, level);
if (lazy < 0) {