diff options
author | Victor Stinner <vstinner@python.org> | 2024-09-04 11:41:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-04 11:41:57 (GMT) |
commit | 0d6b6e34a2980d3d9c342f7ce66e82a39eca295e (patch) | |
tree | c38c5c8a6cc98b0a5ab16ee211a829d2214d9b9f /Doc | |
parent | 7d2c2f24daf7a2abd166bb51652ba55c6f55695f (diff) | |
download | cpython-0d6b6e34a2980d3d9c342f7ce66e82a39eca295e.zip cpython-0d6b6e34a2980d3d9c342f7ce66e82a39eca295e.tar.gz cpython-0d6b6e34a2980d3d9c342f7ce66e82a39eca295e.tar.bz2 |
gh-107954, PEP 741: Add PyInitConfig_AddModule() function (#123668)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/init_config.rst | 20 | ||||
-rw-r--r-- | Doc/whatsnew/3.14.rst | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst index b59be98..94085ce 100644 --- a/Doc/c-api/init_config.rst +++ b/Doc/c-api/init_config.rst @@ -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 ----------------- diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 83c13e6..e1bd523 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -524,6 +524,7 @@ New Features * :c:func:`PyInitConfig_SetInt` * :c:func:`PyInitConfig_SetStr` * :c:func:`PyInitConfig_SetStrList` + * :c:func:`PyInitConfig_AddModule` * :c:func:`Py_InitializeFromInitConfig` (Contributed by Victor Stinner in :gh:`107954`.) |