summaryrefslogtreecommitdiffstats
path: root/Doc/library/importlib.rst
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2014-01-25 22:32:46 (GMT)
committerEric Snow <ericsnowcurrently@gmail.com>2014-01-25 22:32:46 (GMT)
commit6029e086911be873b2ebacb933e3df08c23084e4 (patch)
treed91555f72eacd791ecf1bdd9d169bf82ea28a49d /Doc/library/importlib.rst
parent128ee220e21bd4e7eb152396ff24d879f38c5d91 (diff)
downloadcpython-6029e086911be873b2ebacb933e3df08c23084e4.zip
cpython-6029e086911be873b2ebacb933e3df08c23084e4.tar.gz
cpython-6029e086911be873b2ebacb933e3df08c23084e4.tar.bz2
Issue 19944: Fix importlib.find_spec() so it imports parents as needed.
The function is also moved to importlib.util.
Diffstat (limited to 'Doc/library/importlib.rst')
-rw-r--r--Doc/library/importlib.rst34
1 files changed, 17 insertions, 17 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index a3373e0..e2c826c 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -89,22 +89,6 @@ Functions
.. versionchanged:: 3.3
Parent packages are automatically imported.
-.. function:: find_spec(name, path=None)
-
- Find the :term:`spec <module spec>` for a module, optionally within the
- specified *path*. If the module is in :attr:`sys.modules`, then
- ``sys.modules[name].__spec__`` is returned (unless the spec would be
- ``None`` or is not set, in which case :exc:`ValueError` is raised).
- Otherwise a search using :attr:`sys.meta_path` is done. ``None`` is
- returned if no spec is found.
-
- A dotted name does not have its parent implicitly imported as that requires
- loading them and that may not be desired. To properly import a submodule you
- will need to import all parent packages of the submodule and use the correct
- argument to *path*.
-
- .. versionadded:: 3.4
-
.. function:: find_loader(name, path=None)
Find the loader for a module, optionally within the specified *path*. If the
@@ -125,7 +109,7 @@ Functions
attribute is set to ``None``.
.. deprecated:: 3.4
- Use :func:`find_spec` instead.
+ Use :func:`importlib.util.find_spec` instead.
.. function:: invalidate_caches()
@@ -1111,6 +1095,22 @@ an :term:`importer`.
.. versionadded:: 3.3
+.. function:: find_spec(name, package=None)
+
+ Find the :term:`spec <module spec>` for a module, optionally relative to
+ the specified **package** name. If the module is in :attr:`sys.modules`,
+ then ``sys.modules[name].__spec__`` is returned (unless the spec would be
+ ``None`` or is not set, in which case :exc:`ValueError` is raised).
+ Otherwise a search using :attr:`sys.meta_path` is done. ``None`` is
+ returned if no spec is found.
+
+ If **name** is for a submodule (contains a dot), the parent module is
+ automatically imported.
+
+ **name** and **package** work the same as for :func:`import_module`.
+
+ .. versionadded:: 3.4
+
.. decorator:: module_for_loader
A :term:`decorator` for :meth:`importlib.abc.Loader.load_module`