This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to branch master
in repository sanlock.
commit 7c697440cb0946926402a02a7534cf2272226853
Author: Amit Bawer <abawer(a)redhat.com>
AuthorDate: Tue Jun 4 00:15:37 2019 +0300
python: Apply pypath_converter to get_alignment API
We should be able to parse device path as either unicode or bytes.
New stub test was added for get_alignment API for path premutations
with no xfails expected.
---
python/sanlock.c | 16 ++++++++++------
tests/python_test.py | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c
index 1a983ee..334b237 100644
--- a/python/sanlock.c
+++ b/python/sanlock.c
@@ -352,17 +352,17 @@ Get device alignment.");
static PyObject *
py_get_alignment(PyObject *self __unused, PyObject *args)
{
- int rv;
- const char *path;
+ int rv = -1;
+ PyObject *path = NULL;
struct sanlk_disk disk;
/* parse python tuple */
- if (!PyArg_ParseTuple(args, "s", &path)) {
- return NULL;
+ if (!PyArg_ParseTuple(args, "O&", pypath_converter, &path)) {
+ goto finally;
}
memset(&disk, 0, sizeof(struct sanlk_disk));
- strncpy(disk.path, path, SANLK_PATH_LEN - 1);
+ strncpy(disk.path, PyBytes_AsString(path), SANLK_PATH_LEN - 1);
/* get device alignment (gil disabled) */
Py_BEGIN_ALLOW_THREADS
@@ -371,9 +371,13 @@ py_get_alignment(PyObject *self __unused, PyObject *args)
if (rv < 0) {
__set_exception(rv, "Unable to get device alignment");
- return NULL;
+ goto finally;
}
+finally:
+ Py_XDECREF(path);
+ if (rv < 0)
+ return NULL;
return Py_BuildValue("i", rv);
}
diff --git a/tests/python_test.py b/tests/python_test.py
index 56d0c99..b251c07 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -636,7 +636,7 @@ def test_init_resource_parse_args(no_sanlock_daemon, name, filename,
encoding):
with raises_sanlock_errno(errno.ENOENT):
sanlock.init_resource(name, b"res_name", disks)
-(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES)
+(a)pytest.mark.parametrize("filename,encoding", FILE_NAMES_NO_XFAILS)
def test_get_alignment_parse_args(no_sanlock_daemon, filename, encoding):
path = util.generate_path("/tmp/", filename, encoding)
with raises_sanlock_errno(errno.ENOENT):
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date