summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-01-25 04:56:30 +0000
committerBrett Cannon <bcannon@gmail.com>2009-01-25 04:56:30 +0000
commit78246b6b457ea65cd33a71076a387d9127fe1a6d (patch)
treeecd83b5eaae87a03c75d330b6b10ec8f5d9719e2
parent51d4aabf09fa0107a7263a45ad85ab3c0398390b (diff)
downloadcpython-git-78246b6b457ea65cd33a71076a387d9127fe1a6d.tar.gz
Document both importlib.machinery.BuiltinImporter and FrozenImporter.
-rw-r--r--Doc/library/importlib.rst48
-rw-r--r--Lib/importlib/NOTES6
-rw-r--r--Lib/importlib/_bootstrap.py4
3 files changed, 49 insertions, 9 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 3f33cfb5df..ea56981315 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -61,7 +61,7 @@ providing custom importers can be found in :pep:`302`.
Functions
---------
-.. function:: __import__(name, globals={}, locals={}, fromlist=\[\], level=0)
+.. function:: __import__(name, globals={}, locals={}, fromlist=list(), level=0)
An implementation of the built-in :func:`__import__` function. See the
built-in function's documentation for usage instructions.
@@ -76,3 +76,49 @@ Functions
package name (e.g. ``import_module('..mod', 'pkg.subpkg')`` will import
``pkg.mod``). The specified module will be inserted into
:data:`sys.modules` and returned.
+
+
+:mod:`importlib.machinery` -- Importers and path hooks
+------------------------------------------------------
+
+.. module:: importlib.machinery
+ :synopsis: Importers and path hooks
+
+This module contains the various objects that help :keyword:`import`
+find and load modules.
+
+.. class:: BuiltinImporter
+
+ :term:`Importer` for built-in modules. All known built-in modules are
+ listed in :data:`sys.builtin_module_names`.
+
+ Only class methods are defined by this class to alleviate the need for
+ instantiation.
+
+ .. method:: find_module(fullname, path=None)
+
+ Class method that allows this class to be a :term:`finder` for built-in
+ modules.
+
+ .. method:: load_module(fullname)
+
+ Class method that allows this class to be a :term:`loader` for built-in
+ modules.
+
+
+.. class:: FrozenImporter
+
+ :term:`Importer` for frozen modules.
+
+ Only class methods are defined by this class to alleviate the need for
+ instantiation.
+
+ .. method:: find_module(fullname, path=None)
+
+ Class method that allows this class to be a :term:`finder` for frozen
+ modules.
+
+ .. method:: load_module(fullname)
+
+ Class method that allows this class to be a :term:`loader` for frozen
+ modules.
diff --git a/Lib/importlib/NOTES b/Lib/importlib/NOTES
index 028f78948c..6d6464c28a 100644
--- a/Lib/importlib/NOTES
+++ b/Lib/importlib/NOTES
@@ -1,12 +1,6 @@
to do
/////
-* Document:
-
- + The terms "importer", "finder", and "loader".
- + machinery.BuiltinImporter.
- + machinery.FrozenImporter.
-
* Expose resolve_name().
* Backport to Python 2.7.
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index d11513adc3..c1d09dd2f7 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -110,8 +110,8 @@ class BuiltinImporter:
return None
return cls if imp.is_builtin(fullname) else None
- @staticmethod
- def load_module(fullname):
+ @classmethod
+ def load_module(cls, fullname):
"""Load a built-in module."""
if fullname not in sys.builtin_module_names:
raise ImportError("{0} is not a built-in module".format(fullname))