From: Noel Power Date: Mon, 5 Feb 2018 11:39:58 +0000 (+0000) Subject: python3 port for param module X-Git-Tag: talloc-2.1.13~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac888471b05e9529b84c221177ec820bde1be893;p=thirdparty%2Fsamba.git python3 port for param module Signed-off-by: Noel Power Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/source3/param/pyparam.c b/source3/param/pyparam.c index ddd17ca4b5f..4f80a0ef864 100644 --- a/source3/param/pyparam.c +++ b/source3/param/pyparam.c @@ -19,6 +19,7 @@ #include #include "includes.h" +#include "python/py3compat.h" #include "param/param.h" #include "param/loadparm.h" #include "lib/talloc/pytalloc.h" @@ -66,22 +67,31 @@ static PyMethodDef pyparam_methods[] = { { NULL } }; -void initparam(void) +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + .m_name = "param", + .m_doc = "Parsing and writing Samba3 configuration files.", + .m_size = -1, + .m_methods = pyparam_methods, +}; + +MODULE_INIT_FUNC(param) { - PyObject *m, *mod; + PyObject *m = NULL, *mod = NULL; - m = Py_InitModule3("param", pyparam_methods, "Parsing and writing Samba3 configuration files."); + m = PyModule_Create(&moduledef); if (m == NULL) - return; + return NULL; mod = PyImport_ImportModule("samba.param"); if (mod == NULL) { - return; + return NULL; } loadparm_Type = (PyTypeObject *)PyObject_GetAttrString(mod, "LoadParm"); Py_DECREF(mod); if (loadparm_Type == NULL) { - return; + return NULL; } + return m; } diff --git a/source3/param/wscript_build b/source3/param/wscript_build index c60e917dba0..c9c42a35625 100644 --- a/source3/param/wscript_build +++ b/source3/param/wscript_build @@ -14,7 +14,8 @@ bld.SAMBA_GENERATOR('s3_param_proto_h', group='build_source', rule='${PYTHON} ${SRC[0].abspath(env)} --file ${SRC[1].abspath(env)} --output ${TGT} --mode=S3PROTO') -bld.SAMBA3_PYTHON('pys3param', +for env in bld.gen_python_environments(): + bld.SAMBA3_PYTHON('pys3param', source='pyparam.c', deps='smbconf', public_deps='samba-hostconfig pytalloc-util talloc',