This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
commit 1ec25a7e2a6e599980b117b085963e755f6973fb
Author: Amit Bawer <abawer(a)redhat.com>
AuthorDate: Tue Jun 4 00:27:27 2019 +0300
python: Apply pypath_converter to write_lockspace API
We should be able to parse lockspace path as either unicode or bytes.
Stub for write_lockspace test was set with additional permutations
over paths with no expected xfails.
---
python/sanlock.c | 9 +++++----
tests/python_test.py | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 2b64b35..6be0e64 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -537,7 +537,7 @@ py_write_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
long align = ALIGNMENT_1M;
uint32_t io_timeout = 0;
PyObject *lockspace = NULL;
- const char *path;
+ PyObject *path = NULL;
struct sanlk_lockspace ls;
static char *kwlist[] = {"lockspace", "path", "offset",
"max_hosts",
@@ -547,15 +547,15 @@ py_write_lockspace(PyObject *self __unused, PyObject *args, PyObject
*keywds)
memset(&ls, 0, sizeof(struct sanlk_lockspace));
/* parse python tuple */
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&s|kiIli", kwlist,
- convert_to_pybytes, &lockspace, &path, &ls.host_id_disk.offset,
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "O&O&|kiIli",
kwlist,
+ convert_to_pybytes, &lockspace, pypath_converter, &path,
&ls.host_id_disk.offset,
&max_hosts, &io_timeout, &align, §or)) {
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);
/* set alignment/sector flags */
if (add_align_flag(align, &ls.flags) == -1)
@@ -576,6 +576,7 @@ py_write_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 fb95977..23851df 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -543,7 +543,7 @@ def test_add_lockspace_parse_args(no_sanlock_daemon, name, filename,
encoding):
@pytest.mark.parametrize("name", LOCKSPACE_OR_RESOURCE_NAMES)
-(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES_NO_XFAILS)
def test_write_lockspace_parse_args(no_sanlock_daemon, name, filename, encoding):
path = util.generate_path("/tmp/", filename, encoding)
with raises_sanlock_errno():
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.