From: biao716.wang Date: Mon, 8 May 2023 05:24:29 +0000 (+0900) Subject: fix run error: Py_InitModule not exist in python3.x X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F292428%2F5;p=tools%2Fyum-metadata-parser.git fix run error: Py_InitModule not exist in python3.x Change PyInt_FromLong to PyLong_FromLong Change PyString_FromString to PyUnicode_FromString Change-Id: Ie0b171fe5b909294271789aac18cbf1db6950a1b Signed-off-by: biao716.wang --- diff --git a/sqlitecache.c b/sqlitecache.c index 3857be7..330af63 100644 --- a/sqlitecache.c +++ b/sqlitecache.c @@ -347,8 +347,8 @@ progress_cb (UpdateInfo *update_info) Py_INCREF(repoid); args = PyTuple_New (3); - PyTuple_SET_ITEM (args, 0, PyInt_FromLong (update_info->packages_seen)); - PyTuple_SET_ITEM (args, 1, PyInt_FromLong (update_info->count_from_md)); + PyTuple_SET_ITEM (args, 0, PyLong_FromLong (update_info->packages_seen)); + PyTuple_SET_ITEM (args, 1, PyLong_FromLong (update_info->count_from_md)); PyTuple_SET_ITEM (args, 2, repoid); result = PyEval_CallObject (progress, args); @@ -517,8 +517,8 @@ log_cb (const gchar *log_domain, break; } - PyTuple_SET_ITEM (args, 0, PyInt_FromLong (level)); - PyTuple_SET_ITEM (args, 1, PyString_FromString (message)); + PyTuple_SET_ITEM (args, 0, PyLong_FromLong (level)); + PyTuple_SET_ITEM (args, 1, PyUnicode_FromString (message)); result = PyEval_CallObject (callback, args); Py_DECREF (args); @@ -552,7 +552,7 @@ py_update (PyObject *self, PyObject *args, UpdateInfo *update_info) g_log_remove_handler (NULL, log_id); if (db_filename) { - ret = PyString_FromString (db_filename); + ret = PyUnicode_FromString (db_filename); g_free (db_filename); } else { PyErr_SetString (PyExc_TypeError, err->message); @@ -621,13 +621,29 @@ static PyMethodDef SqliteMethods[] = { {NULL, NULL, 0, NULL} }; -PyMODINIT_FUNC -init_sqlitecache (void) +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "_sqlitecache", /* m_name */ + NULL, /* m_doc */ + 0, /* m_size */ + SqliteMethods, /* m_methods */ + NULL, /* m_reload */ + NULL, + NULL, + NULL /* m_free */ +}; + +PyObject * PyInit__sqlitecache(void); +PyObject * PyInit__sqlitecache(void) { PyObject * m, * d; - m = Py_InitModule ("_sqlitecache", SqliteMethods); - + m = PyModule_Create (&moduledef); + if (m == NULL) { + return NULL; + } d = PyModule_GetDict(m); - PyDict_SetItemString(d, "DBVERSION", PyInt_FromLong(YUM_SQLITE_CACHE_DBVERSION)); + PyDict_SetItemString(d, "DBVERSION", PyLong_FromLong(YUM_SQLITE_CACHE_DBVERSION)); + + return m; }