diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index d83f5e6a637..6e64bb9a060 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -20,6 +20,7 @@ */ #include +#include "python/py3compat.h" #include "includes.h" #include "python/modules.h" #include "libcli/util/pyerrors.h" @@ -36,7 +37,6 @@ #include #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 2b6cf81885c..4929ccdf515 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 1c3f8dedd15..eed0551824b 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' )