Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/54309 )
Change subject: sim,python: Use scoped_interpreter_guard's argc and argv
ctor arguments.
......................................................................
sim,python: Use scoped_interpreter_guard's argc and argv ctor arguments.
When pybind11's scoped_interpreter_guard is constructed, it can take
argc and argv parameters which it uses to intitialize the sys.argv list
in python. We can use that mechanism instead of setting that up manually
ourselves.
Change-Id: If34fac610d1f829aef313bb9ea4c9dfe6bc8fc0f
---
M src/sim/main.cc
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/src/sim/main.cc b/src/sim/main.cc
index c44531e..81a691d 100644
--- a/src/sim/main.cc
+++ b/src/sim/main.cc
@@ -60,28 +60,11 @@
// It's probably not necessary, but is mostly harmless and might be
useful.
Py_SetProgramName(program.get());
- py::scoped_interpreter guard;
+ py::scoped_interpreter guard(true, argc, argv);
auto importer = py::module_::import("importer");
importer.attr("install")();
- // Embedded python doesn't set up sys.argv, so we'll do that ourselves.
- py::list py_argv;
- auto sys = py::module::import("sys");
- if (py::hasattr(sys, "argv")) {
- // sys.argv already exists, so grab that.
- py_argv = sys.attr("argv");
- } else {
- // sys.argv doesn't exist, so create it.
- sys.add_object("argv", py_argv);
- }
- // Clear out argv just in case it has something in it.
- py_argv.attr("clear")();
-
- // Fill it with our argvs.
- for (int i = 0; i < argc; i++)
- py_argv.append(argv[i]);
-
try {
py::module_::import("m5").attr("main")();
} catch (py::error_already_set &e) {
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/54309
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: release-staging-v21-2
Gerrit-Change-Id: If34fac610d1f829aef313bb9ea4c9dfe6bc8fc0f
Gerrit-Change-Number: 54309
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s