[3.13] gh-141004: Document PyImport_Inittab (GH-141844) (GH-142016)
Some checks are pending
Tests / Docs (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run

(cherry picked from commit 5f35702bb6)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Stan Ulbrych 2025-11-27 19:20:58 +00:00 committed by GitHub
parent 80b752285d
commit 3bbd669abb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 4 deletions

View file

@ -325,3 +325,10 @@ Importing Modules
If Python is initialized multiple times, :c:func:`PyImport_AppendInittab` or
:c:func:`PyImport_ExtendInittab` must be called before each Python
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.

View file

@ -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::

View file

@ -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.

View file

@ -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.
..