From: Georg Brandl Date: Sun, 7 Dec 2008 22:45:56 +0000 (+0000) Subject: #4586: fix usage of Py_InitModule. X-Git-Tag: v3.1a1~723 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05b482caf89fe8b1f678dafaebef1030486a87b2;p=python #4586: fix usage of Py_InitModule. --- diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst index c86ae8ab2a..e5c7da19d9 100644 --- a/Doc/extending/embedding.rst +++ b/Doc/extending/embedding.rst @@ -218,11 +218,16 @@ Python extension. For example:: {NULL, NULL, 0, NULL} }; + static PyModuleDef EmbModule = { + PyModuleDef_HEAD_INIT, "emb", NULL, -1, EmbMethods, + NULL, NULL, NULL, NULL + }; + Insert the above code just above the :cfunc:`main` function. Also, insert the following two statements directly after :cfunc:`Py_Initialize`:: numargs = argc; - Py_InitModule("emb", EmbMethods); + PyModule_Create(&EmbModule); These two lines initialize the ``numargs`` variable, and make the :func:`emb.numargs` function accessible to the embedded Python interpreter.