Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 15 additions & 80 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ ABC hierarchy::
.. versionchanged:: 3.7
Introduced the optional :meth:`get_resource_reader` method.

.. versionchanged:: 3.15
Removed the ``load_module()`` method.

.. method:: create_module(spec)

A method that returns the module object to use when
Expand All @@ -344,47 +347,6 @@ ABC hierarchy::
.. versionchanged:: 3.6
:meth:`create_module` must also be defined.

.. method:: load_module(fullname)

A legacy method for loading a module. If the module cannot be
loaded, :exc:`ImportError` is raised, otherwise the loaded module is
returned.

If the requested module already exists in :data:`sys.modules`, that
module should be used and reloaded.
Otherwise the loader should create a new module and insert it into
:data:`sys.modules` before any loading begins, to prevent recursion
from the import. If the loader inserted a module and the load fails, it
must be removed by the loader from :data:`sys.modules`; modules already
in :data:`sys.modules` before the loader began execution should be left
alone.

The loader should set several attributes on the module
(note that some of these attributes can change when a module is
reloaded):

- :attr:`module.__name__`
- :attr:`module.__file__`
- :attr:`module.__cached__` *(deprecated)*
- :attr:`module.__path__`
- :attr:`module.__package__` *(deprecated)*
- :attr:`module.__loader__` *(deprecated)*

When :meth:`exec_module` is available then backwards-compatible
functionality is provided.

.. versionchanged:: 3.4
Raise :exc:`ImportError` when called instead of
:exc:`NotImplementedError`. Functionality provided when
:meth:`exec_module` is available.

.. deprecated-removed:: 3.4 3.15
The recommended API for loading a module is :meth:`exec_module`
(and :meth:`create_module`). Loaders should implement it instead of
:meth:`load_module`. The import machinery takes care of all the
other responsibilities of :meth:`load_module` when
:meth:`exec_module` is implemented.


.. class:: ResourceLoader

Expand Down Expand Up @@ -490,13 +452,6 @@ ABC hierarchy::

.. versionadded:: 3.4

.. method:: load_module(fullname)

Implementation of :meth:`Loader.load_module`.

.. deprecated-removed:: 3.4 3.15
use :meth:`exec_module` instead.


.. class:: ExecutionLoader

Expand Down Expand Up @@ -530,6 +485,9 @@ ABC hierarchy::

.. versionadded:: 3.3

.. versionchanged:: 3.15
Removed the ``load_module()`` method.

.. attribute:: name

The name of the module the loader can handle.
Expand All @@ -538,13 +496,6 @@ ABC hierarchy::

Path to the file of the module.

.. method:: load_module(fullname)

Calls super's ``load_module()``.

.. deprecated-removed:: 3.4 3.15
Use :meth:`Loader.exec_module` instead.

.. method:: get_filename(fullname)
:abstractmethod:

Expand Down Expand Up @@ -576,6 +527,9 @@ ABC hierarchy::
optimization to speed up loading by removing the parsing step of Python's
compiler, and so no bytecode-specific API is exposed.

.. versionchanged:: 3.15
Removed the ``load_module()`` method.

.. method:: path_stats(path)

Optional abstract method which returns a :class:`dict` containing
Expand Down Expand Up @@ -629,13 +583,6 @@ ABC hierarchy::

.. versionadded:: 3.4

.. method:: load_module(fullname)

Concrete implementation of :meth:`Loader.load_module`.

.. deprecated-removed:: 3.4 3.15
Use :meth:`exec_module` instead.

.. method:: get_source(fullname)

Concrete implementation of :meth:`InspectLoader.get_source`.
Expand Down Expand Up @@ -1059,6 +1006,9 @@ find and load modules.

.. versionadded:: 3.3

.. versionchanged:: 3.15
Removed the ``load_module()`` method.

.. attribute:: name

The name of the module that this loader will handle.
Expand All @@ -1079,15 +1029,6 @@ find and load modules.

Concrete implementation of :meth:`importlib.abc.SourceLoader.set_data`.

.. method:: load_module(name=None)

Concrete implementation of :meth:`importlib.abc.Loader.load_module` where
specifying the name of the module to load is optional.

.. deprecated-removed:: 3.6 3.15

Use :meth:`importlib.abc.Loader.exec_module` instead.


.. class:: SourcelessFileLoader(fullname, path)

Expand All @@ -1101,6 +1042,9 @@ find and load modules.

.. versionadded:: 3.3

.. versionchanged:: 3.15
Removed the ``load_module()`` method.

.. attribute:: name

The name of the module the loader will handle.
Expand All @@ -1122,15 +1066,6 @@ find and load modules.
Returns ``None`` as bytecode files have no source when this loader is
used.

.. method:: load_module(name=None)

Concrete implementation of :meth:`importlib.abc.Loader.load_module` where
specifying the name of the module to load is optional.

.. deprecated-removed:: 3.6 3.15

Use :meth:`importlib.abc.Loader.exec_module` instead.


.. class:: ExtensionFileLoader(fullname, path)

Expand Down
Loading
Loading