summaryrefslogtreecommitdiffstats
path: root/Doc/extending
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-12-07 22:45:56 (GMT)
committerGeorg Brandl <georg@python.org>2008-12-07 22:45:56 (GMT)
commit05b482caf89fe8b1f678dafaebef1030486a87b2 (patch)
tree26f97648a9a652a7ede0cdb7b9d2f13808d1e808 /Doc/extending
parentd153afea66e691f1327a34a932f4a1a2b0146db3 (diff)
downloadcpython-05b482caf89fe8b1f678dafaebef1030486a87b2.zip
cpython-05b482caf89fe8b1f678dafaebef1030486a87b2.tar.gz
cpython-05b482caf89fe8b1f678dafaebef1030486a87b2.tar.bz2
#4586: fix usage of Py_InitModule.
Diffstat (limited to 'Doc/extending')
-rw-r--r--Doc/extending/embedding.rst7
1 files changed, 6 insertions, 1 deletions
diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst
index c86ae8a..e5c7da1 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.