fm-common: updated initfm_core to PyInit_fm_core

According with python 3 migration rules:
PyMODINIT_FUNC init<yourmodulename>(void)
has changed to below in Python 3:
PyMODINIT_FUNC PyInit_<yourmodulename>(void)
otherwise there is below issue:
CRITICAL sysinv [-] Unhandled error: ImportError: dynamic module does not define module export function (PyInit_fm_core)
ERROR sysinv Traceback (most recent call last):
ERROR sysinv   File "/usr/bin/sysinv-puppet", line 10, in <module>

Story: 2008454
Task: 41440

Signed-off-by: Haiqing Bai <haiqing.bai@windriver.com>
Change-Id: Id51da7f328b41ec389cf2e073db7ff6617398339
(cherry picked from commit cd1487e1a5)
This commit is contained in:
Haiqing Bai 2020-12-17 18:43:30 +08:00 committed by Charles Short
parent c9857c8cf4
commit 0da6a24471
1 changed files with 14 additions and 1 deletions

View File

@ -313,8 +313,21 @@ static PyMethodDef _methods [] = {
{ NULL, NULL, 0, NULL }
};
static struct PyModuleDef cModPyDem =
{
PyModuleDef_HEAD_INIT,
"fm_core", /* name of module */
"", /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */
_methods
};
#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC PyInit_fm_core() {
#else
PyMODINIT_FUNC initfm_core() {
PyObject *m = Py_InitModule("fm_core", _methods);
#endif
PyObject *m = PyModule_Create(&cModPyDem);
if (m == NULL){
PySys_WriteStderr("Failed to initialize fm_core");
return;