bpo-44441: _PyImport_Fini2() resets PyImport_Inittab (GH-26874) (GH-26877)
Py_RunMain() now resets PyImport_Inittab to its initial value at
exit. It must be possible to call PyImport_AppendInittab() or
PyImport_ExtendInittab() at each Python initialization.
(cherry picked from commit 489699ca05bed5cfd10e847d8580840812b476cd)
diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst
index c6fc330..d2ae6b6 100644
--- a/Doc/c-api/import.rst
+++ b/Doc/c-api/import.rst
@@ -299,4 +299,8 @@
field; failure to provide the sentinel value can result in a memory fault.
Returns ``0`` on success or ``-1`` if insufficient memory could be allocated to
extend the internal table. In the event of failure, no modules are added to the
- internal table. This should be called before :c:func:`Py_Initialize`.
+ internal table. This must be called before :c:func:`Py_Initialize`.
+
+ If Python is initialized multiple times, :c:func:`PyImport_AppendInittab` or
+ :c:func:`PyImport_ExtendInittab` must be called before each Python
+ initialization.
diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst
index de85029..fe5b83a 100644
--- a/Doc/c-api/init_config.rst
+++ b/Doc/c-api/init_config.rst
@@ -1193,7 +1193,10 @@
If :c:func:`PyImport_FrozenModules`, :c:func:`PyImport_AppendInittab` or
:c:func:`PyImport_ExtendInittab` are used, they must be set or called after
-Python preinitialization and before the Python initialization.
+Python preinitialization and before the Python initialization. If Python is
+initialized multiple times, :c:func:`PyImport_AppendInittab` or
+:c:func:`PyImport_ExtendInittab` must be called before each Python
+initialization.
The current configuration (``PyConfig`` type) is stored in
``PyInterpreterState.config``.