sim: Squash a long standing warning from pybind11.
The module_ constructor which takes a module name and an optional docstring is deprecated. This change replaces it with the create_extension_module call that it would result in, which gets rid of the warning. Change-Id: I700b4afcf1e5e2548af18e2eb2a7b1214c989807 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50587 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -193,7 +193,17 @@ EmbeddedPyBind::initAll()
|
||||
{
|
||||
std::list<EmbeddedPyBind *> pending;
|
||||
|
||||
py::module_ m_m5 = py::module_("_m5");
|
||||
// The PyModuleDef structure needs to live as long as the module it
|
||||
// defines, so we'll leak it here so it lives forever. This is what
|
||||
// pybind11 does internally in the module_ constructor we were using. We
|
||||
// could theoretically keep track of the lifetime of the _m5 module
|
||||
// somehow and clean this up when it goes away, but that doesn't seem
|
||||
// worth the effort. The docs recommend statically allocating it, but that
|
||||
// could be unsafe on the very slim chance this method is called more than
|
||||
// once.
|
||||
auto *py_mod_def = new py::module_::module_def;
|
||||
py::module_ m_m5 = py::module_::create_extension_module(
|
||||
"_m5", nullptr, py_mod_def);
|
||||
m_m5.attr("__package__") = py::cast("_m5");
|
||||
|
||||
pybind_init_core(m_m5);
|
||||
|
||||
Reference in New Issue
Block a user