mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
#4586: fix usage of Py_InitModule.
This commit is contained in:
parent
d153afea66
commit
05b482caf8
1 changed files with 6 additions and 1 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue