]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python: Port dsdb_dns module to Python 3 compatible form.
authorLumir Balhar <lbalhar@redhat.com>
Tue, 30 Jan 2018 17:47:32 +0000 (18:47 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 14 Feb 2018 23:18:28 +0000 (00:18 +0100)
Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dns_server/pydns.c
source4/dns_server/wscript_build

index 63fa80e92b3c65b371ebcfbb1cbf542befd698ad..a4441ddef5622086a801f162d38f655d2f798a82 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include <Python.h>
+#include "python/py3compat.h"
 #include "includes.h"
 #include <pyldb.h>
 #include <pytalloc.h>
@@ -333,14 +334,22 @@ static PyMethodDef py_dsdb_dns_methods[] = {
        { NULL }
 };
 
-void initdsdb_dns(void);
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    .m_name = "dsdb_dns",
+    .m_doc = "Python bindings for the DNS objects in the directory service databases.",
+    .m_size = -1,
+    .m_methods = py_dsdb_dns_methods,
+};
 
-void initdsdb_dns(void)
+MODULE_INIT_FUNC(dsdb_dns)
 {
        PyObject *m;
 
-       m = Py_InitModule3("dsdb_dns", py_dsdb_dns_methods,
-                          "Python bindings for the DNS objects in the directory service databases.");
+       m = PyModule_Create(&moduledef);
+
        if (m == NULL)
-               return;
+               return NULL;
+
+       return m;
 }
index 47701e0f293bbbac4fd451f233e026665dda0b18..c24f45584a432ead2656e5ee2bfd3f9f0479da35 100644 (file)
@@ -65,8 +65,12 @@ bld.SAMBA_LIBRARY('dlz_bind9_for_torture',
                   deps='samba-hostconfig samdb-common gensec popt dnsserver_common',
                   enabled=bld.AD_DC_BUILD_IS_ENABLED())
 
+for env in bld.gen_python_environments():
+    pyldb_util = bld.pyembed_libname('pyldb-util')
+    pyrpc_util = bld.pyembed_libname('pyrpc_util')
+    pytalloc_util = bld.pyembed_libname('pytalloc-util')
 
-bld.SAMBA_PYTHON('python_dsdb_dns',
+    bld.SAMBA_PYTHON('python_dsdb_dns',
                 source='pydns.c',
-                deps='samdb pyldb-util pyrpc_util dnsserver_common pytalloc-util',
+                deps='samdb %s %s dnsserver_common %s' % (pyldb_util, pyrpc_util, pytalloc_util),
                 realname='samba/dsdb_dns.so')