From a67c04f3666d92a66f4a4c5e0b4788fe4949cd22 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 10 Sep 2019 01:09:09 -0500 Subject: [PATCH] bup_stat bup_lstat: always treat path as binary Convert the path via "y" in Python 3, and rename the format alias to cstr_argf to more accurately reflect what it means, i.e. a sequence of non-null bytes. If "y" ends up being sufficient it's simpler (and more efficient?) than a Py_buffer conversion, though it doesn't support as many argument types. Signed-off-by: Rob Browning --- lib/bup/_helpers.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index a03452a..592c121 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -74,10 +74,10 @@ typedef struct { #if PY_MAJOR_VERSION < 3 static state_t state; # define get_state(x) (&state) -# define buf_argf "s" +# define cstr_argf "s" #else # define get_state(x) ((state_t *) PyModule_GetState(x)) -# define buf_argf "y" +# define cstr_argf "y" #endif // PY_MAJOR_VERSION >= 3 @@ -1408,7 +1408,7 @@ static PyObject *bup_stat(PyObject *self, PyObject *args) int rc; char *filename; - if (!PyArg_ParseTuple(args, "s", &filename)) + if (!PyArg_ParseTuple(args, cstr_argf, &filename)) return NULL; struct stat st; @@ -1424,7 +1424,7 @@ static PyObject *bup_lstat(PyObject *self, PyObject *args) int rc; char *filename; - if (!PyArg_ParseTuple(args, "s", &filename)) + if (!PyArg_ParseTuple(args, cstr_argf, &filename)) return NULL; struct stat st; @@ -1481,7 +1481,7 @@ static PyObject *bup_mincore(PyObject *self, PyObject *args) Py_buffer src, dest; PyObject *py_src_n, *py_src_off, *py_dest_off; - if (!PyArg_ParseTuple(args, buf_argf "*OOw*O", + if (!PyArg_ParseTuple(args, cstr_argf "*OOw*O", &src, &py_src_n, &py_src_off, &dest, &py_dest_off)) return NULL; -- 2.39.2