From: Amit Bawer <abawer(a)redhat.com>
At this stage building the sanlock module for Py3 is
expected to fail as we have modifications to be done
in upcoming patches to fill in missing Py3 API calls.
---
python/sanlock.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/python/sanlock.c b/python/sanlock.c
index 420b4ba..aa3b9a8 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -1775,10 +1775,38 @@ module_init(PyObject* m)
}
return 0;
}
+#if PY_MAJOR_VERSION >= 3 /* Python 3 module init */
+
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ MODULE_NAME,
+ pydoc_sanlock,
+ -1,
+ sanlock_methods,
+};
+
+PyMODINIT_FUNC
+PyInit_sanlock(void)
+{
+ PyObject *m = PyModule_Create(&moduledef);
+
+ if (m == NULL)
+ return NULL;
+
+ if (module_init(m)) {
+ Py_DECREF(m);
+ return NULL;
+ }
+
+ return m;
+}
+
+#else /* Python 2 module init */
+
PyMODINIT_FUNC
initsanlock(void)
{
PyObject *m = Py_InitModule3(
MODULE_NAME,
@@ -1790,6 +1818,8 @@ initsanlock(void)
/* We don't have anything to do if module_init() fails. */
module_init(m);
}
+#endif
+
/* vim: set expandtab shiftwidth=4 tabstop=4 : */
--
2.17.2