]> arthur.barton.de Git - bup.git/commitdiff
bup_stat bup_lstat: always treat path as binary
authorRob Browning <rlb@defaultvalue.org>
Tue, 10 Sep 2019 06:09:09 +0000 (01:09 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 29 Sep 2019 20:25:18 +0000 (15:25 -0500)
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 <rlb@defaultvalue.org>
lib/bup/_helpers.c

index a03452a163c64dcd6acbfc1b05c9d5f5d99a74f7..592c1217d077ad3c9e5ae68b6ea517927c485a84 100644 (file)
@@ -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;