python: Remove unnecessary Python 2.x workaround
We needed to explicitly cast the return value from getCode() to int to avoid a Python 2.x issue where sys.exit() got confused by an unexpected long argument. This isn't an issue in Python 3 since long has been removed as a separate type. Change-Id: I7770d0f180e826ac7e6c92c13bc6a61447e3f851 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50407 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -134,18 +134,7 @@ pybind_init_event(py::module_ &m_native)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user