From e34dfb56ffe65ea05ef4a54622849e1a47b72c37 Mon Sep 17 00:00:00 2001 From: Thomas Roehr Date: Thu, 30 Apr 2020 13:47:26 +0200 Subject: [PATCH] Fix ubuntu 19.04 error RuntimeError: FATAL: module compiled as little endian, but detected different endianness at runtime see also https://github.com/ros-perception/vision_opencv/pull/292 and https://github.com/ros-melodic-arch/ros-melodic-cv-bridge/pull/2 --- plugins/PythonMars/src/PythonInterpreter.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/PythonMars/src/PythonInterpreter.cpp b/plugins/PythonMars/src/PythonInterpreter.cpp index 5a6a1b1db..5b9c3162b 100644 --- a/plugins/PythonMars/src/PythonInterpreter.cpp +++ b/plugins/PythonMars/src/PythonInterpreter.cpp @@ -279,7 +279,7 @@ struct ListBuilderState bool knownType = true; if(PyBool_Check(obj)) { - item = (bool)PyObject_IsTrue(obj); + item = (bool)PyObject_IsTrue(obj); } else if(PyInt_Check(obj)) { item = (int)PyInt_AsLong(obj); @@ -288,10 +288,10 @@ struct ListBuilderState item = PyFloat_AsDouble(obj); } else if(PyString_Check(obj)) { - item = PyString_AsString(obj); + item = PyString_AsString(obj); } else if(PyList_Check(obj)) { - const unsigned size = PyList_Size(obj); + const unsigned size = PyList_Size(obj); for(unsigned i = 0; i < size; i++) { PyObject *elem = PyList_GetItem(obj, i); item[(int)i] = ConfigItem(); @@ -300,7 +300,7 @@ struct ListBuilderState } else if(PyDict_Check(obj)) { PyObject *keyList = PyDict_Keys(obj); - const unsigned size = PyList_Size(keyList); + const unsigned size = PyList_Size(keyList); for(unsigned i = 0; i < size; i++) { PyObject *key = PyList_GetItem(keyList, i); item[std::string(PyString_AsString(key))]; @@ -324,7 +324,7 @@ struct ListBuilderState PyObject* obj = mapToPyObjectPtr_(it->second); if(obj) { PyDict_SetItemString(dict, it->first.c_str(), obj); - Py_XDECREF(obj); + Py_XDECREF(obj); } } return dict; @@ -334,9 +334,9 @@ struct ListBuilderState ConfigVector::iterator it = map->begin(); for(; it!=map->end(); ++it) { PyObject* obj = mapToPyObjectPtr_(*it); - if(obj) { + if(obj) { PyList_Append(list, obj); - Py_XDECREF(obj); + Py_XDECREF(obj); } } return list; @@ -360,7 +360,7 @@ struct ListBuilderState } return NULL; } - + PyObjectPtr mapToPyObjectPtr(ConfigMap *map) { ConfigItem item(*map); return makePyObjectPtr(mapToPyObjectPtr_(&item)); @@ -444,6 +444,7 @@ struct ListBuilderState #if PYTHON_VERSION == 3 int initNumpy() { import_array(); + return NULL; #else void initNumpy() { import_array();