Skip to content

Commit

Permalink
Fix logging for failed load.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Aug 11, 2024
1 parent 54e05d3 commit e155907
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/proxy/proxypython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}
Expand Down
7 changes: 7 additions & 0 deletions src/runner/pythonrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e155907

Please sign in to comment.