Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/50587 )

Change subject: sim: Squash a long standing warning from pybind11.
......................................................................

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 <[email protected]>
Reviewed-by: Andreas Sandberg <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/sim/init.cc
1 file changed, 11 insertions(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Andreas Sandberg: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/sim/init.cc b/src/sim/init.cc
index 0c69958..ed54742 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -193,7 +193,17 @@
 {
     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);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/50587
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I700b4afcf1e5e2548af18e2eb2a7b1214c989807
Gerrit-Change-Number: 50587
Gerrit-PatchSet: 2
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to