This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master in repository sanlock.
commit aa7011dea8ca4a0b1f8bc8cc35daf78d3d79b37e Author: Amit Bawer abawer@redhat.com AuthorDate: Tue Jun 4 00:52:00 2019 +0300
python: Apply pypath_converter to add_lockspace
We should be able to parse lockspace path as either unicode or bytes.
New stub test is added for add_lockpace API with path permutation 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 a846570..4b7c810 100644 --- a/python/sanlock.c +++ b/python/sanlock.c @@ -813,7 +813,7 @@ py_add_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds) int rv = -1, async = 0, flags = 0; uint32_t iotimeout = 0; PyObject *lockspace = NULL; - const char *path; + PyObject *path = NULL; struct sanlk_lockspace ls;
static char *kwlist[] = {"lockspace", "host_id", "path", "offset", @@ -823,9 +823,9 @@ py_add_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, - &iotimeout, &async)) { + if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&kO&|kIi", kwlist, + convert_to_pybytes, &lockspace, &ls.host_id, pypath_converter, &path, + &ls.host_id_disk.offset, &iotimeout, &async)) { goto finally; }
@@ -836,7 +836,7 @@ py_add_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 @@ -850,6 +850,7 @@ py_add_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 3ce1301..a9933f4 100644 --- a/tests/python_test.py +++ b/tests/python_test.py @@ -535,7 +535,7 @@ def test_rem_lockspace_parse_args(no_sanlock_daemon, name, filename, encoding):
@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_add_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