From 1c07d75320e9f07ce5dc88aaf6e7b31cad8c8c1d Mon Sep 17 00:00:00 2001 From: Charles Short Date: Tue, 7 Sep 2021 08:40:25 -0400 Subject: [PATCH] Fix python3.9 building PyString_FromString has been removed from python3.9, use PyUnicode_FromString instead since its backwards compatible with python2.7. Story: 2009101 Task: 43219 Signed-off-by: Charles Short Change-Id: I9535e0f36d56dd5ae15c1ffea27fdf0877de0484 --- fm-common/sources/fm_python_mod_main.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/fm-common/sources/fm_python_mod_main.cpp b/fm-common/sources/fm_python_mod_main.cpp index 4ec6950d..40a83017 100644 --- a/fm-common/sources/fm_python_mod_main.cpp +++ b/fm-common/sources/fm_python_mod_main.cpp @@ -6,11 +6,8 @@ #if PY_MAJOR_VERSION >= 3 #define PY_SSIZE_T_CLEAN -#include -#define PyString_FromString PyUnicode_FromString -#else -#include #endif +#include #include #include "fmAPI.h" #include "fmAlarmUtils.h" @@ -89,7 +86,7 @@ static PyObject * _fm_set(PyObject * self, PyObject *args) { rc = fm_set_fault(&alm_data, &tmp_uuid); if (rc == FM_ERR_OK) { - return PyString_FromString(&(tmp_uuid[0])); + return PyUnicode_FromString(&(tmp_uuid[0])); } if (rc == FM_ERR_NOCONNECT){ @@ -125,7 +122,7 @@ static PyObject * _fm_get(PyObject * self, PyObject *args) { rc = fm_get_fault(&af,&ad); if (rc == FM_ERR_OK) { fm_alarm_to_string(&ad,alm_str); - return PyString_FromString(alm_str.c_str()); + return PyUnicode_FromString(alm_str.c_str()); } if (rc == FM_ERR_ENTITY_NOT_FOUND) { @@ -170,7 +167,7 @@ static PyObject * _fm_get_by_aid(PyObject * self, PyObject *args, PyObject* kwar std::string s; fm_alarm_to_string(&lst[ix],s); if (s.size() > 0) { - if (PyList_Append(__lst, PyString_FromString(s.c_str())) != 0) { + if (PyList_Append(__lst, PyUnicode_FromString(s.c_str())) != 0) { ERROR_LOG("Failed to append alarm to the list"); } } @@ -219,7 +216,7 @@ static PyObject * _fm_get_by_eid(PyObject * self, PyObject *args, PyObject* kwar std::string s; fm_alarm_to_string(&lst[ix], s); if (s.size() > 0) { - if (PyList_Append(__lst,PyString_FromString(s.c_str())) != 0) { + if (PyList_Append(__lst,PyUnicode_FromString(s.c_str())) != 0) { ERROR_LOG("Failed to append alarm to the list"); } }