Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f26702b

Browse files
committed
Issue #21157: Touch up imp docs to be more explicit about importlib
alternatives.
1 parent 5fbc7b1 commit f26702b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Doc/library/imp.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ This module provides an interface to the mechanisms used to implement the
7979
When *P* itself has a dotted name, apply this recipe recursively.
8080

8181
.. deprecated:: 3.3
82-
Use :func:`importlib.find_loader` instead.
82+
Use :func:`importlib.util.find_spec` instead unless Python 3.3
83+
compatibility is required, in which case use
84+
:func:`importlib.find_loader`.
8385

8486

8587
.. function:: load_module(name, file, pathname, description)
@@ -104,9 +106,11 @@ This module provides an interface to the mechanisms used to implement the
104106

105107
.. deprecated:: 3.3
106108
If previously used in conjunction with :func:`imp.find_module` then
107-
call ``load_module()`` on the returned loader. If you wish to load a
108-
module from a specific file, then use one of the file-based loaders found
109-
in :mod:`importlib.machinery`.
109+
consider using :func:`importlib.import_module`, otherwise use the loader
110+
returned by the replacement you chose for :func:`imp.find_module`. If you
111+
called :func:`imp.load_module` and related functions directly then use the
112+
classes in :mod:`importlib.machinery`, e.g.
113+
``importlib.machinery.SourceFileLoader(name, path).load_module()``.
110114

111115

112116
.. function:: new_module(name)

0 commit comments

Comments
 (0)