[Python-checkins] cpython (3.4): Issue #21157: Touch up imp docs to be more explicit about importlib

brett.cannon python-checkins at python.org
Fri May 9 16:38:08 CEST 2014


http://hg.python.org/cpython/rev/9809a791436d
changeset:   90598:9809a791436d
branch:      3.4
parent:      90595:64ba3f2de99c
user:        Brett Cannon <brett at python.org>
date:        Fri May 09 10:37:31 2014 -0400
summary:
  Issue #21157: Touch up imp docs to be more explicit about importlib
alternatives.

files:
  Doc/library/imp.rst |  12 ++++++++----
  1 files changed, 8 insertions(+), 4 deletions(-)


diff --git a/Doc/library/imp.rst b/Doc/library/imp.rst
--- a/Doc/library/imp.rst
+++ b/Doc/library/imp.rst
@@ -79,7 +79,9 @@
    When *P* itself has a dotted name, apply this recipe recursively.
 
    .. deprecated:: 3.3
-      Use :func:`importlib.find_loader` instead.
+      Use :func:`importlib.util.find_spec` instead unless Python 3.3
+      compatibility is required, in which case use
+      :func:`importlib.find_loader`.
 
 
 .. function:: load_module(name, file, pathname, description)
@@ -104,9 +106,11 @@
 
    .. deprecated:: 3.3
       If previously used in conjunction with :func:`imp.find_module` then
-      call ``load_module()`` on the returned loader. If you wish to load a
-      module from a specific file, then use one of the file-based loaders found
-      in :mod:`importlib.machinery`.
+      consider using :func:`importlib.import_module`, otherwise use the loader
+      returned by the replacement you chose for :func:`imp.find_module`. If you
+      called :func:`imp.load_module` and related functions directly then use the
+      classes in :mod:`importlib.machinery`, e.g.
+      ``importlib.machinery.SourceFileLoader(name, path).load_module()``.
 
 
 .. function:: new_module(name)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list