gh-145076: Check globals type in __lazy_import__() (#145086)

This commit is contained in:
Victor Stinner 2026-02-21 22:06:59 +01:00 committed by GitHub
parent fbd3b25e00
commit 2be2dd5fc2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View file

@ -318,6 +318,12 @@ builtin___lazy_import___impl(PyObject *module, PyObject *name,
locals = globals;
}
if (!PyDict_Check(globals)) {
PyErr_Format(PyExc_TypeError,
"expect dict for globals, got %T", globals);
return NULL;
}
if (PyDict_GetItemRef(globals, &_Py_ID(__builtins__), &builtins) < 0) {
return NULL;
}