[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Mon Oct 23 13:41:02 UTC 2017


The branch, master has been updated
       via  e583a92 python: Port tests of samba.messaging to Python 3 compatible form.
       via  806c1bc python: Port samba.messaging module to Python 3 compatible form.
      from  c3a1348 xattr.idl: Don't generate an interface table

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e583a926eb92a59fafab65830195bae582826198
Author: Lumir Balhar <lbalhar at redhat.com>
Date:   Thu Sep 14 09:31:17 2017 +0200

    python: Port tests of samba.messaging to Python 3 compatible form.
    
    Signed-off-by: Lumir Balhar <lbalhar at redhat.com>
    Reviewed-by: Andrew Bartlet <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Mon Oct 23 15:40:48 CEST 2017 on sn-devel-144

commit 806c1bcacdce707b23369fe268bf5220d5224c45
Author: Lumir Balhar <lbalhar at redhat.com>
Date:   Thu Sep 14 09:30:28 2017 +0200

    python: Port samba.messaging module to Python 3 compatible form.
    
    Signed-off-by: Lumir Balhar <lbalhar at redhat.com>
    Reviewed-by: Andrew Bartlet <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 python/samba/compat.py              |  5 +++++
 python/samba/tests/messaging.py     |  4 +++-
 selftest/tests.py                   |  3 ++-
 source4/lib/messaging/pymessaging.c | 22 ++++++++++++++++------
 source4/lib/messaging/wscript_build | 14 +++++++++-----
 source4/librpc/wscript_build        |  2 +-
 6 files changed, 36 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/compat.py b/python/samba/compat.py
index c8215f3..dfdfb7d 100644
--- a/python/samba/compat.py
+++ b/python/samba/compat.py
@@ -20,3 +20,8 @@
 import sys
 
 PY3 = sys.version_info[0] == 3
+
+if PY3:
+    integer_types = int,
+else:
+    integer_types = (int, long)
diff --git a/python/samba/tests/messaging.py b/python/samba/tests/messaging.py
index 41834c1..2a3685f 100644
--- a/python/samba/tests/messaging.py
+++ b/python/samba/tests/messaging.py
@@ -26,6 +26,8 @@ from samba.ndr import ndr_print
 from samba.dcerpc import server_id
 import random
 import os
+from samba.compat import integer_types
+
 
 class MessagingTests(TestCase):
 
@@ -38,7 +40,7 @@ class MessagingTests(TestCase):
         def callback():
             pass
         msg_type = x.register((callback, None))
-        self.assertTrue(isinstance(msg_type, long))
+        self.assertTrue(isinstance(msg_type, integer_types))
         x.deregister(callback, msg_type)
 
     def test_all_servers(self):
diff --git a/selftest/tests.py b/selftest/tests.py
index 639bc63..704dbad 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -73,7 +73,8 @@ planpythontestsuite("none", "samba.tests.dcerpc.rpc_talloc")
 planpythontestsuite("none", "samba.tests.dcerpc.array")
 planpythontestsuite("none", "samba.tests.dcerpc.string")
 planpythontestsuite("none", "samba.tests.hostconfig")
-planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.messaging")
+planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.messaging",
+                    py3_compatible=True)
 planpythontestsuite("none", "samba.tests.samba3sam")
 planpythontestsuite(
     "none", "wafsamba.tests.test_suite",
diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c
index d83f5e6..6e64bb9 100644
--- a/source4/lib/messaging/pymessaging.c
+++ b/source4/lib/messaging/pymessaging.c
@@ -20,6 +20,7 @@
 */
 
 #include <Python.h>
+#include "python/py3compat.h"
 #include "includes.h"
 #include "python/modules.h"
 #include "libcli/util/pyerrors.h"
@@ -36,7 +37,6 @@
 #include <pytalloc.h>
 #include "messaging_internal.h"
 
-void initmessaging(void);
 
 extern PyTypeObject imessaging_Type;
 
@@ -493,7 +493,7 @@ static PyGetSetDef py_imessaging_getset[] = {
 
 
 PyTypeObject imessaging_Type = {
-	PyObject_HEAD_INIT(NULL) 0,
+	PyVarObject_HEAD_INIT(NULL, 0)
 	.tp_name = "messaging.Messaging",
 	.tp_basicsize = sizeof(imessaging_Object),
 	.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
@@ -505,19 +505,29 @@ PyTypeObject imessaging_Type = {
 		  "Create a new object that can be used to communicate with the peers in the specified messaging path.\n"
 };
 
-void initmessaging(void)
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    .m_name = "messaging",
+    .m_doc = "Internal RPC",
+    .m_size = -1,
+    .m_methods = NULL,
+};
+
+MODULE_INIT_FUNC(messaging)
 {
 	PyObject *mod;
 
 	if (PyType_Ready(&imessaging_Type) < 0)
-		return;
+		return NULL;
 
-	mod = Py_InitModule3("messaging", NULL, "Internal RPC");
+	mod = PyModule_Create(&moduledef);
 	if (mod == NULL)
-		return;
+		return NULL;
 
 	Py_INCREF((PyObject *)&imessaging_Type);
 	PyModule_AddObject(mod, "Messaging", (PyObject *)&imessaging_Type);
 	PyModule_AddObject(mod, "IRPC_CALL_TIMEOUT", PyInt_FromLong(IRPC_CALL_TIMEOUT));
 	PyModule_AddObject(mod, "IRPC_CALL_TIMEOUT_INF", PyInt_FromLong(IRPC_CALL_TIMEOUT_INF));
+
+	return mod;
 }
diff --git a/source4/lib/messaging/wscript_build b/source4/lib/messaging/wscript_build
index 2b6cf81..4929ccd 100644
--- a/source4/lib/messaging/wscript_build
+++ b/source4/lib/messaging/wscript_build
@@ -13,9 +13,13 @@ bld.SAMBA_LIBRARY('MESSAGING',
 	private_library=True
 	)
 
-bld.SAMBA_PYTHON('python_messaging',
-	source='pymessaging.c',
-	deps='MESSAGING events pyparam_util pytalloc-util',
-	realname='samba/messaging.so'
-	)
+for env in bld.gen_python_environments():
+
+	pyparam_util = bld.pyembed_libname('pyparam_util')
+	pytalloc_util = bld.pyembed_libname('pytalloc-util')
 
+	bld.SAMBA_PYTHON('python_messaging',
+		source='pymessaging.c',
+		deps='MESSAGING events pyparam_util pytalloc-util',
+		realname='samba/messaging.so'
+		)
diff --git a/source4/librpc/wscript_build b/source4/librpc/wscript_build
index 1c3f8de..eed0551 100644
--- a/source4/librpc/wscript_build
+++ b/source4/librpc/wscript_build
@@ -338,7 +338,7 @@ for env in bld.gen_python_environments():
 
 	bld.SAMBA_PYTHON('python_irpc',
 		source='gen_ndr/py_irpc.c',
-		deps='RPC_NDR_IRPC pytalloc-util pyrpc_util',
+		deps='RPC_NDR_IRPC %s %s' % (pytalloc_util, pyrpc_util),
 		realname='samba/dcerpc/irpc.so'
 		)
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list