gh-107954, PEP 741: Add PyInitConfig_AddModule() function (#123668)

This commit is contained in:
Victor Stinner 2024-09-04 13:41:57 +02:00 committed by GitHub
parent 7d2c2f24da
commit 0d6b6e34a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 121 additions and 0 deletions

View file

@ -1744,6 +1744,26 @@ only implemented when ``Py_InitializeFromInitConfig()`` is called, not by the
* Set an error in *config* and return ``-1`` on error.
Module
------
.. c:function:: int PyInitConfig_AddModule(PyInitConfig *config, const char *name, PyObject* (*initfunc)(void))
Add a built-in extension module to the table of built-in modules.
The new module can be imported by the name *name*, and uses the function
*initfunc* as the initialization function called on the first attempted
import.
* Return ``0`` on success.
* Set an error in *config* and return ``-1`` on error.
If Python is initialized multiple times, ``PyInitConfig_AddModule()`` must
be called at each Python initialization.
Similar to the :c:func:`PyImport_AppendInittab` function.
Initialize Python
-----------------