From: Rob Browning Date: Tue, 10 Sep 2019 06:09:09 +0000 (-0500) Subject: bup_stat bup_lstat: always treat path as binary X-Git-Tag: 0.31~281 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=a67c04f3666d92a66f4a4c5e0b4788fe4949cd22 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 --- 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;