This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master in repository sanlock.
commit d105239b7a3c9bce3f39fd11807af038b4ff0fff Author: Amit Bawer abawer@redhat.com AuthorDate: Tue Jun 4 00:56:07 2019 +0300
python: Apply pypath_converter to inq_lockspace API
We would like to parse lockspace path as either unicode or bytes.
Stub test for inq_lockspace API is set with additional permutation for paths with no xfails expected. --- python/sanlock.c | 11 ++++++----- tests/python_test.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c index 4b7c810..e3b63a7 100644 --- a/python/sanlock.c +++ b/python/sanlock.c @@ -870,7 +870,7 @@ py_inq_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds) { int rv = BIND_ERROR, waitrs = 0, flags = 0; PyObject *lockspace = NULL; - const char *path; + PyObject *path = NULL; struct sanlk_lockspace ls;
static char *kwlist[] = {"lockspace", "host_id", "path", "offset", @@ -880,9 +880,9 @@ py_inq_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds) memset(&ls, 0, sizeof(struct sanlk_lockspace));
/* parse python tuple */ - if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&ks|ki", kwlist, - convert_to_pybytes, &lockspace, &ls.host_id, &path, &ls.host_id_disk.offset, - &waitrs)) { + if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&kO&|ki", kwlist, + convert_to_pybytes, &lockspace, &ls.host_id, pypath_converter, &path, + &ls.host_id_disk.offset, &waitrs)) { goto finally; }
@@ -893,7 +893,7 @@ py_inq_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
/* prepare sanlock names */ strncpy(ls.name, PyBytes_AsString(lockspace), SANLK_NAME_LEN); - strncpy(ls.host_id_disk.path, path, SANLK_PATH_LEN - 1); + strncpy(ls.host_id_disk.path, PyBytes_AsString(path), SANLK_PATH_LEN - 1);
/* add sanlock lockspace (gil disabled) */ Py_BEGIN_ALLOW_THREADS @@ -902,6 +902,7 @@ py_inq_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
finally: Py_XDECREF(lockspace); + Py_XDECREF(path);
if (rv == BIND_ERROR) { return NULL; diff --git a/tests/python_test.py b/tests/python_test.py index a9933f4..2be57e0 100644 --- a/tests/python_test.py +++ b/tests/python_test.py @@ -593,7 +593,7 @@ def test_get_hosts_parse_args(no_sanlock_daemon, name):
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES) -@pytest.mark.parametrize("filename,encoding", FILE_NAMES) +@pytest.mark.parametrize("filename,encoding", FILE_NAMES_NO_XFAILS) def test_inq_lockspace_parse_args(no_sanlock_daemon, name, filename, encoding): path = util.generate_path("/tmp/", filename, encoding) with raises_sanlock_errno():
sanlock-devel@lists.fedorahosted.org