summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-05-13 17:45:09 (GMT)
committerBrett Cannon <brett@python.org>2012-05-13 17:45:09 (GMT)
commitd200bf534b6d97ee607e1071d0cb2d93e4506268 (patch)
tree2aab0e9eb36b8362d0d6ee2afe1e2245b69d1cbf /Doc
parent61009468c5be2757c50c9b7bd14582788b83a646 (diff)
downloadcpython-d200bf534b6d97ee607e1071d0cb2d93e4506268.zip
cpython-d200bf534b6d97ee607e1071d0cb2d93e4506268.tar.gz
cpython-d200bf534b6d97ee607e1071d0cb2d93e4506268.tar.bz2
Add importlib.util.resolve_name().
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/importlib.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 0bc1b65..35a99bf 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -737,6 +737,22 @@ find and load modules.
This module contains the various objects that help in the construction of
an :term:`importer`.
+.. function:: resolve_name(name, package)
+
+ Resolve a relative module name to an absolute one.
+
+ If **name** has no leading dots, then **name** is simply returned. This
+ allows for usage such as
+ ``importlib.util.resolve_name('sys', __package__)`` without doing a
+ check to see if the **package** argument is needed.
+
+ :exc:`ValueError` is raised if **name** is a relative module name but
+ package is a false value (e.g. ``None`` or the empty string).
+ :exc:`ValueError` is also raised a relative name would escape its containing
+ package (e.g. requesting ``..bacon`` from within the ``spam`` package).
+
+ .. versionadded:: 3.3
+
.. decorator:: module_for_loader
A :term:`decorator` for a :term:`loader` method,