fix error path in _PyImport_LazyImportModuleLevelObject

This commit is contained in:
Bénédikt Tran 2025-12-07 11:41:47 +01:00 committed by T. Wouters
parent 74f35c42cb
commit 301481631f

View file

@ -4371,7 +4371,9 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate,
Py_DECREF(filter);
Py_DECREF(abs_name);
return NULL;
} else if (modname == NULL) {
}
if (modname == NULL) {
assert(!PyErr_Occurred());
modname = Py_NewRef(Py_None);
}
PyObject *args[] = {modname, name, fromlist};
@ -4405,6 +4407,7 @@ _PyImport_LazyImportModuleLevelObject(PyThreadState *tstate,
}
}
// here, 'filter' is either NULL or is equivalent to a borrowed reference
PyObject *res = _PyLazyImport_New(builtins, abs_name, fromlist);
if (res == NULL) {
Py_DECREF(abs_name);