From: Amit Bawer <abawer(a)redhat.com>
Preserve compatibility for both Py3 and Py2.
- Py2: will construct new PyInt
- Py3: will construct new PyLong
Both Py versions will build and pass tests at this point.
---
python/sanlock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 6477afe..b412b6a 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -271,11 +271,11 @@ py_register(PyObject *self __unused, PyObject *args)
if (sanlockfd < 0) {
__set_exception(sanlockfd, "Sanlock registration failed");
return NULL;
}
- return PyInt_FromLong(sanlockfd);
+ return Py_BuildValue("i", sanlockfd);
}
/* get_alignment */
PyDoc_STRVAR(pydoc_get_alignment, "\
get_alignment(path) -> int\n\
@@ -304,11 +304,11 @@ py_get_alignment(PyObject *self __unused, PyObject *args)
if (rv < 0) {
__set_exception(rv, "Unable to get device alignment");
return NULL;
}
- return PyInt_FromLong(rv);
+ return Py_BuildValue("i", rv);
}
/* init_lockspace */
PyDoc_STRVAR(pydoc_init_lockspace, "\
init_lockspace(lockspace, path, offset=0, max_hosts=0, num_hosts=0, \
--
2.17.2