s4/ntvfs/posix/python: python3 (get|set)xattr value should be bytes
authorNoel Power <noel.power@suse.com>
Tue, 6 Mar 2018 15:03:13 +0000 (15:03 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 5 Apr 2018 06:59:09 +0000 (08:59 +0200)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
source4/ntvfs/posix/python/pyposix_eadb.c
source4/ntvfs/posix/python/pyxattr_native.c
source4/ntvfs/posix/python/pyxattr_tdb.c

index d43c7c47bb79f7fd25eab648e2ae883a1939733a..646498225b3960561d1b6447cc371ed349aa4b7c 100644 (file)
@@ -43,7 +43,7 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args)
        TALLOC_CTX *mem_ctx;
        struct tdb_wrap *eadb;
 
-       if (!PyArg_ParseTuple(args, "ssss#", &tdbname, &filename, &attribute,
+       if (!PyArg_ParseTuple(args, "sss"PYARG_BYTES_LEN, &tdbname, &filename, &attribute,
                                                  &blob.data, &blobsize))
                return NULL;
 
@@ -101,7 +101,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
                talloc_free(mem_ctx);
                return NULL;
        }
-       ret = PyStr_FromStringAndSize((char *)blob.data, blob.length);
+       ret = Py_BuildValue(PYARG_BYTES_LEN, blob.data, blob.length);
        talloc_free(mem_ctx);
        return ret;
 }
index c5e740fe577ac4154891622e324b19b85897d180..b1fa2a208e5432ff52b3183a2a11893f6fe4c00c 100644 (file)
@@ -41,7 +41,7 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args)
        Py_ssize_t blobsize;
        DATA_BLOB blob;
 
-       if (!PyArg_ParseTuple(args, "sss#", &filename, &attribute, &blob.data, 
+       if (!PyArg_ParseTuple(args, "ss"PYARG_BYTES_LEN, &filename, &attribute, &blob.data,
         &blobsize))
                return NULL;
 
@@ -90,7 +90,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
                talloc_free(mem_ctx);
                return NULL;
        }
-       ret = PyStr_FromStringAndSize(buf, len);
+       ret = Py_BuildValue(PYARG_BYTES_LEN, buf, len);
        talloc_free(mem_ctx);
        return ret;
 }
index 05303b6aa00ab1890c6a9b777488eb429bea2fc6..f9a1fa5fd80c301870126cf5502400b4f57c9171 100644 (file)
@@ -50,7 +50,7 @@ static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args)
        struct file_id id;
        struct stat sbuf;
 
-       if (!PyArg_ParseTuple(args, "ssss#", &tdbname, &filename, &attribute, 
+       if (!PyArg_ParseTuple(args, "sss"PYARG_BYTES_LEN, &tdbname, &filename, &attribute,
                                                  &blob.data, &blobsize))
                return NULL;
 
@@ -137,7 +137,7 @@ static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args)
                talloc_free(mem_ctx);
                return NULL;
        }
-       ret_obj = PyStr_FromStringAndSize((char *)blob.data, xattr_size);
+       ret_obj = Py_BuildValue(PYARG_BYTES_LEN, blob.data, xattr_size);
        talloc_free(mem_ctx);
        return ret_obj;
 }