summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/c-api/import.rst15
-rw-r--r--Doc/whatsnew/3.9.rst3
-rw-r--r--Include/import.h1
-rw-r--r--Include/internal/pycore_import.h1
-rw-r--r--Python/import.c3
-rw-r--r--Python/pylifecycle.c4
6 files changed, 7 insertions, 20 deletions
diff --git a/Doc/c-api/import.rst b/Doc/c-api/import.rst
index 86cc403..3bc5060 100644
--- a/Doc/c-api/import.rst
+++ b/Doc/c-api/import.rst
@@ -223,21 +223,6 @@ Importing Modules
Return a new reference to the finder object.
-.. c:function:: void _PyImport_Init()
-
- Initialize the import mechanism. For internal use only.
-
-
-.. c:function:: void PyImport_Cleanup()
-
- Empty the module table. For internal use only.
-
-
-.. c:function:: void _PyImport_Fini()
-
- Finalize the import mechanism. For internal use only.
-
-
.. c:function:: int PyImport_ImportFrozenModuleObject(PyObject *name)
Load a frozen module named *name*. Return ``1`` for success, ``0`` if the
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index 446c8b9..24fbe18 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -122,6 +122,9 @@ Deprecated
Removed
=======
+* The C function ``PyImport_Cleanup()`` has been removed. It was documented as:
+ "Empty the module table. For internal use only."
+
* ``_dummy_thread`` and ``dummy_threading`` modules have been removed. These
modules were deprecated since Python 3.7 which requires threading support.
(Contributed by Victor Stinner in :issue:`37312`.)
diff --git a/Include/import.h b/Include/import.h
index c50767d..735533e 100644
--- a/Include/import.h
+++ b/Include/import.h
@@ -72,7 +72,6 @@ PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
-PyAPI_FUNC(void) PyImport_Cleanup(void);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
PyObject *name
diff --git a/Include/internal/pycore_import.h b/Include/internal/pycore_import.h
index bbcd170..5d3203e 100644
--- a/Include/internal/pycore_import.h
+++ b/Include/internal/pycore_import.h
@@ -11,6 +11,7 @@ PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
);
extern void _PyImport_ReInitLock(void);
+extern void _PyImport_Cleanup(PyThreadState *tstate);
#ifdef __cplusplus
}
diff --git a/Python/import.c b/Python/import.c
index 5606d3b..dc0d5b8 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -413,9 +413,8 @@ static const char * const sys_files[] = {
/* Un-initialize things, as good as we can */
void
-PyImport_Cleanup(void)
+_PyImport_Cleanup(PyThreadState *tstate)
{
- PyThreadState *tstate = _PyThreadState_GET();
PyInterpreterState *interp = tstate->interp;
PyObject *modules = interp->modules;
if (modules == NULL) {
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 4a97295..c0b3450 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1225,7 +1225,7 @@ Py_FinalizeEx(void)
_PySys_ClearAuditHooks();
/* Destroy all modules */
- PyImport_Cleanup();
+ _PyImport_Cleanup(tstate);
/* Print debug stats if any */
_PyEval_Fini();
@@ -1589,7 +1589,7 @@ Py_EndInterpreter(PyThreadState *tstate)
if (tstate != interp->tstate_head || tstate->next != NULL)
Py_FatalError("Py_EndInterpreter: not the last thread");
- PyImport_Cleanup();
+ _PyImport_Cleanup(tstate);
PyInterpreterState_Clear(interp);
PyThreadState_Swap(NULL);
PyInterpreterState_Delete(interp);