https://github.com/python/cpython/commit/9e309c140fec1b53a5630ca9d954426e437c130a commit: 9e309c140fec1b53a5630ca9d954426e437c130a branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity <[email protected]> date: 2025-11-24T12:16:31-05:00 summary:
[3.14] gh-141004: Document `PyImport_Inittab` (GH-141844) (GH-141915) gh-141004: Document `PyImport_Inittab` (GH-141844) (cherry picked from commit 5f35702bb641230131c400500bb8bbacde7465b2) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Stan Ulbrych <[email protected]> Co-authored-by: Victor Stinner <[email protected]> files: M Doc/c-api/import.rst M Doc/extending/extending.rst M Misc/NEWS.d/3.11.0a1.rst M Misc/NEWS.d/3.12.0a2.rst diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst index 1cab3ce3061ec9..369e95dd02251b 100644 --- a/Doc/c-api/import.rst +++ b/Doc/c-api/import.rst @@ -327,6 +327,13 @@ Importing Modules initialization. +.. c:var:: struct _inittab *PyImport_Inittab + + The table of built-in modules used by Python initialization. Do not use this directly; + use :c:func:`PyImport_AppendInittab` and :c:func:`PyImport_ExtendInittab` + instead. + + .. c:function:: PyObject* PyImport_ImportModuleAttr(PyObject *mod_name, PyObject *attr_name) Import the module *mod_name* and get its attribute *attr_name*. diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst index dee92312169a27..f9b65643dfe888 100644 --- a/Doc/extending/extending.rst +++ b/Doc/extending/extending.rst @@ -426,7 +426,7 @@ A pointer to the module definition must be returned via :c:func:`PyModuleDef_Ini so that the import machinery can create the module and store it in ``sys.modules``. When embedding Python, the :c:func:`!PyInit_spam` function is not called -automatically unless there's an entry in the :c:data:`!PyImport_Inittab` table. +automatically unless there's an entry in the :c:data:`PyImport_Inittab` table. To add the module to the initialization table, use :c:func:`PyImport_AppendInittab`, optionally followed by an import of the module:: diff --git a/Misc/NEWS.d/3.11.0a1.rst b/Misc/NEWS.d/3.11.0a1.rst index f58d6b657e9b95..ab998ca73abf40 100644 --- a/Misc/NEWS.d/3.11.0a1.rst +++ b/Misc/NEWS.d/3.11.0a1.rst @@ -4931,7 +4931,7 @@ Patch by Gabriele N. Tornetta .. nonce: 3p14JB .. section: C API -:c:func:`Py_RunMain` now resets :c:data:`!PyImport_Inittab` to its initial +:c:func:`Py_RunMain` now resets :c:data:`PyImport_Inittab` to its initial value at exit. It must be possible to call :c:func:`PyImport_AppendInittab` or :c:func:`PyImport_ExtendInittab` at each Python initialization. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/3.12.0a2.rst b/Misc/NEWS.d/3.12.0a2.rst index bc028f30636bf7..20e27c0d92f05f 100644 --- a/Misc/NEWS.d/3.12.0a2.rst +++ b/Misc/NEWS.d/3.12.0a2.rst @@ -35,11 +35,11 @@ Update bundled libexpat to 2.5.0 .. nonce: ik4iOv .. section: Core and Builtins -The docs clearly say that ``PyImport_Inittab``, +The docs clearly say that :c:data:`PyImport_Inittab`, :c:func:`PyImport_AppendInittab`, and :c:func:`PyImport_ExtendInittab` should not be used after :c:func:`Py_Initialize` has been called. We now enforce this for the two functions. Additionally, the runtime now uses an -internal copy of ``PyImport_Inittab``, to guard against modification. +internal copy of :c:data:`PyImport_Inittab`, to guard against modification. .. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
