PEL: Don't use 's#' in Py_BuildValue
When python was updated to 3.11 from 3.9, the call to
PyObject_CallObject started segmentation faulting when the 's#' format
specifier was used by Py_BuildValue to build the tuple of arguments
to call the parseSRCToJson() python plugin function with.
I didn't get to the bottom of why it didn't work, but just using 's'
instead is fine. 's' requires the string to be null terminated while
's#' doesn't, but since the code uses a std::string it will always be
null terminated anyway.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I319d466d3dae4833af1ae2c67f7b9f309fd2eb5c
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index 75b291a..8058155 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -187,16 +187,12 @@
&pyDecRef);
for (size_t i = 0; i < 9; i++)
{
+ std::string arg{"00000000"};
if (i < hexwords.size())
{
- auto arg = hexwords[i];
- PyTuple_SetItem(pArgs, i,
- Py_BuildValue("s#", arg.c_str(), 8));
+ arg = hexwords[i];
}
- else
- {
- PyTuple_SetItem(pArgs, i, Py_BuildValue("s", "00000000"));
- }
+ PyTuple_SetItem(pArgs, i, Py_BuildValue("s", arg.c_str()));
}
PyObject* pResult = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pFunc);