diff options
author | Lumir Balhar <lbalhar@redhat.com> | 2017-11-10 09:30:29 +0100 |
---|---|---|
committer | Jiri Kastner <jkastner@redhat.com> | 2017-11-20 13:53:13 +0100 |
commit | 580508c1f9edfad873d8b9610977512d0f7bdaa5 (patch) | |
tree | 85696c6d462711be4b8ed9b77ddae48afd3fbe97 | |
parent | 53aff14ad4b0f7913fec1398d072de01684296ca (diff) | |
download | python-schedutils-580508c1f9edfad873d8b9610977512d0f7bdaa5.tar.gz |
python3: Make schedutils Python 3 compatible
Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Signed-off-by: Jiri Kastner <jkastner@redhat.com>
-rw-r--r-- | python-schedutils/schedutils.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/python-schedutils/schedutils.c b/python-schedutils/schedutils.c index be38e18..79fb0bd 100644 --- a/python-schedutils/schedutils.c +++ b/python-schedutils/schedutils.c @@ -1,4 +1,5 @@ #include <Python.h> +#include "py3compat.h" #include <sched.h> #include <errno.h> #include <syscall.h> @@ -266,7 +267,7 @@ static PyObject *schedstr(PyObject *self __unused, PyObject *args) default: s = "UNKNOWN"; break; } - return PyString_FromString(s); + return PyStr_FromString(s); } static PyObject *schedfromstr(PyObject *self __unused, PyObject *args) @@ -378,11 +379,19 @@ static struct PyMethodDef PySchedutilsModuleMethods[] = { { .ml_name = NULL, }, }; -PyMODINIT_FUNC initschedutils(void) +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + .m_name = "schedutils", + .m_doc = NULL, + .m_size = -1, + .m_methods = PySchedutilsModuleMethods, +}; + +MODULE_INIT_FUNC(schedutils) { - PyObject *m = Py_InitModule("schedutils", PySchedutilsModuleMethods); + PyObject *m = PyModule_Create(&moduledef); if (m == NULL) - return; + return NULL; PyModule_AddIntConstant(m, "SCHED_OTHER", SCHED_OTHER); PyModule_AddIntConstant(m, "SCHED_FIFO", SCHED_FIFO); @@ -391,5 +400,7 @@ PyMODINIT_FUNC initschedutils(void) PyModule_AddIntConstant(m, "SCHED_IDLE", SCHED_IDLE); PyModule_AddIntConstant(m, "SCHED_DEADLINE", SCHED_DEADLINE); PyModule_AddIntConstant(m, "SCHED_RESET_ON_FORK", SCHED_RESET_ON_FORK); + + return m; } |