*/
#include <Python.h>
+#include "python/py3compat.h"
#include "includes.h"
#include "librpc/ndr/libndr.h"
#include "system/filesys.h"
-
-void initxattr_native(void);
+#include "lib/util/base64.h"
static PyObject *py_is_xattr_supported(PyObject *self)
{
{
char *filename, *attribute;
int ret = 0;
- int blobsize;
+ 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;
talloc_free(mem_ctx);
return NULL;
}
- ret = PyString_FromStringAndSize(buf, len);
+ ret = Py_BuildValue(PYARG_BYTES_LEN, buf, len);
talloc_free(mem_ctx);
return ret;
}
static PyMethodDef py_xattr_methods[] = {
{ "wrap_getxattr", (PyCFunction)py_wrap_getxattr, METH_VARARGS,
"wrap_getxattr(filename,attribute) -> blob\n"
- "Retreive given attribute on the given file." },
+ "Retrieve given attribute on the given file." },
{ "wrap_setxattr", (PyCFunction)py_wrap_setxattr, METH_VARARGS,
"wrap_setxattr(filename,attribute,value)\n"
"Set the given attribute to the given value on the given file." },
{ NULL }
};
-void initxattr_native(void)
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "xattr_native",
+ .m_doc = "Python bindings for xattr manipulation.",
+ .m_size = -1,
+ .m_methods = py_xattr_methods,
+};
+
+MODULE_INIT_FUNC(xattr_native)
{
PyObject *m;
- m = Py_InitModule3("xattr_native", py_xattr_methods,
- "Python bindings for xattr manipulation.");
+ m = PyModule_Create(&moduledef);
if (m == NULL)
- return;
-}
+ return NULL;
+ return m;
+}