Fix logging for failed load.

This commit is contained in:
Mikaël Capelle
2024-08-11 11:06:12 +02:00
parent 54e05d31ef
commit e155907d21
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ QList<QList<QObject*>> ProxyPython::load(const PluginExtension& extension)
}
if (extension.autodetect()) {
log::error("{}: automatic plugin detection is not supported for Python plugins",
log::debug("{}: automatic plugin detection is not supported for Python plugins",
extension.metadata().name());
return {};
}
+7
View File
@@ -174,6 +174,13 @@ namespace mo2::python {
// load the module
auto spec =
importlib_util.attr("spec_from_file_location")(name, pythonModule);
if (Py_IsNone(spec.ptr())) {
MOBase::log::error("failed to load Python plugin '{}' from '{}'",
name, pythonModule);
return {};
}
pymodule = importlib_util.attr("module_from_spec")(spec);
sys.attr("modules")[py::str(name)] = pymodule;
spec.attr("loader").attr("exec_module")(pymodule);