Skip to content

Commit

Permalink
Revert "Revert "Replaced deprecated "load_module" with "exec_module"""
Browse files Browse the repository at this point in the history
This reverts commit 59c5010.

pybind/pybind11#3798 (comment)
gives the cause for the real problem
  • Loading branch information
aumuell authored and MDjur committed Feb 17, 2023
1 parent d88de9f commit 6e626c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/vistle/python/pythonmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1592,11 +1592,14 @@ bool PythonModule::import(py::object *ns, const std::string &path)
std::cerr << "Python: loading " << path + "/vistle.py" << std::endl;
#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 6)
py::eval<py::eval_statements>(R"(
import sys
import importlib
import importlib.util
spec = importlib.util.spec_from_file_location(modulename, path)
if spec != None and spec.loader != None:
newmodule = spec.loader.load_module()
newmodule = importlib.util.module_from_spec(spec)
sys.modules[modulename] = newmodule
spec.loader.exec_module(newmodule)
)",
*ns, locals);
#else
Expand Down

0 comments on commit 6e626c0

Please sign in to comment.