This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master in repository sanlock.
commit 083e0236b900564415016db856bccfc22dc409d3 Author: Amit Bawer abawer@redhat.com AuthorDate: Tue Jun 4 01:01:02 2019 +0300
python: Apply pypath_converter to rem_lockspace API
We would like to parse lockspace path as either unicode or bytes.
Stub test for rem_lockspace API is set with additional permutation over path with no expected xfails. --- python/sanlock.c | 10 ++++++---- tests/python_test.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c index e3b63a7..b7ffa28 100644 --- a/python/sanlock.c +++ b/python/sanlock.c @@ -933,7 +933,7 @@ py_rem_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds) { int rv = -1, async = 0, unused = 0, flags = 0; PyObject *lockspace = NULL; - const char *path; + PyObject *path = NULL; struct sanlk_lockspace ls;
static char *kwlist[] = {"lockspace", "host_id", "path", "offset", @@ -943,15 +943,16 @@ py_rem_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|kii", kwlist, - convert_to_pybytes, &lockspace, &ls.host_id, &path, &ls.host_id_disk.offset, + if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&kO&|kii", kwlist, + convert_to_pybytes, &lockspace, &ls.host_id, pypath_converter, &path, + &ls.host_id_disk.offset, &async, &unused)) { goto finally; }
/* 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);
/* prepare sanlock_rem_lockspace flags */ if (async) { @@ -974,6 +975,7 @@ py_rem_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds)
finally: Py_XDECREF(lockspace); + Py_XDECREF(path); if (rv != 0) return NULL; Py_RETURN_NONE; diff --git a/tests/python_test.py b/tests/python_test.py index 2be57e0..a23d2ec 100644 --- a/tests/python_test.py +++ b/tests/python_test.py @@ -527,7 +527,7 @@ def raises_sanlock_errno(expected_errno=errno.ECONNREFUSED):
@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_rem_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