Andreas Sandberg has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/15978
Change subject: python: Remove getCode() type workaround
......................................................................
python: Remove getCode() type workaround
Python 2.7 requires a workaround when wrapping exit objects to
explicitly convert the return of getCode() to int to not confuse
sys.exit. This workaround isn't needed and doesn't work on Python 3
since it doesn't have a separate long integer type.
Change-Id: I57bc3fd8f4699676c046ece8a52baa2796959ffd
Signed-off-by: Andreas Sandberg <[email protected]>
---
M src/python/pybind11/event.cc
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/python/pybind11/event.cc b/src/python/pybind11/event.cc
index d2d78fe..a65ddc6 100644
--- a/src/python/pybind11/event.cc
+++ b/src/python/pybind11/event.cc
@@ -135,10 +135,18 @@
std::unique_ptr<GlobalSimLoopExitEvent, py::nodelete>>(
m, "GlobalSimLoopExitEvent")
.def("getCause", &GlobalSimLoopExitEvent::getCause)
+#if PY_MAJOR_VERSION >= 3
+ .def("getCode", &GlobalSimLoopExitEvent::getCode)
+#else
+ // Workaround for an issue where PyBind11 converts the exit
+ // code to a long. This is normally fine, but sys.exit treats
+ // any non-int type as an error and exits with status 1 if it
+ // is passed a long.
.def("getCode", [](GlobalSimLoopExitEvent *e) {
return py::reinterpret_steal<py::object>(
PyInt_FromLong(e->getCode()));
})
+#endif
;
// Event base class. These should never be returned directly to
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/15978
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I57bc3fd8f4699676c046ece8a52baa2796959ffd
Gerrit-Change-Number: 15978
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev