diff options
author | Brett Cannon <brett@python.org> | 2021-03-30 15:43:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 15:43:03 (GMT) |
commit | a7ff6df60c05e1b69fca743573b1e118bebf121d (patch) | |
tree | 7dae896ba674245645b5ca46c02cc387a43d35a0 /Doc | |
parent | cf35e05f89bb008d6f4553f9875e0fe87fc02406 (diff) | |
download | cpython-a7ff6df60c05e1b69fca743573b1e118bebf121d.zip cpython-a7ff6df60c05e1b69fca743573b1e118bebf121d.tar.gz cpython-a7ff6df60c05e1b69fca743573b1e118bebf121d.tar.bz2 |
bpo-42134: Raise ImportWarning when calling find_module() in the import system (GH-25044)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/reference/import.rst | 11 | ||||
-rw-r--r-- | Doc/whatsnew/3.10.rst | 9 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index b5ac21d..5d2169b 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -329,6 +329,10 @@ modules, and one that knows how to import modules from an :term:`import path` import machinery will try it only if the finder does not implement ``find_spec()``. +.. versionchanged:: 3.10 + Use of :meth:`~importlib.abc.MetaPathFinder.find_module` by the import system + now raises :exc:`ImportWarning`. + Loading ======= @@ -470,6 +474,9 @@ import machinery will create the new module itself. An :exc:`ImportError` is raised when ``exec_module()`` is defined but ``create_module()`` is not. +.. versionchanged:: 3.10 + Use of ``load_module()`` will raise :exc:`ImportWarning`. + Submodules ---------- @@ -896,6 +903,10 @@ a list containing the portion. exist on a path entry finder, the import system will always call ``find_loader()`` in preference to ``find_module()``. +.. versionchanged:: 3.10 + Calls to :meth:`~importlib.abc.PathEntryFinder.find_module` by the import + system will raise :exc:`ImportWarning`. + Replacing the standard import system ==================================== diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 3a563c1..e09cfb4 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1028,6 +1028,15 @@ Deprecated :meth:`~importlib.abc.Loader.exec_module` is preferred. (Contributed by Brett Cannon in :issue:`26131`.) +* The use of :meth:`importlib.abc.MetaPathFinder.find_module` and + :meth:`importlib.abc.PathEntryFinder.find_module` by the import system now + trigger an :exc:`ImportWarning` as + :meth:`importlib.abc.MetaPathFinder.find_spec` and + :meth:`importlib.abc.PathEntryFinder.find_spec` + are preferred, respectively. You can use + :func:`importlib.util.spec_from_loader` to help in porting. + (Contributed by Brett Cannon in :issue:`42134`.) + * The import system now uses the ``__spec__`` attribute on modules before falling back on :meth:`~importlib.abc.Loader.module_repr` for a module's ``__repr__()`` method. Removal of the use of ``module_repr()`` is scheduled |