diff options
author | Brett Cannon <brett@python.org> | 2013-05-28 21:29:34 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-05-28 21:29:34 (GMT) |
commit | a3687f0d6896673689d8dd5c13e113947f66e921 (patch) | |
tree | 6d14bef5ece4b63451cdf2ca59a81fd2cca5de58 /Doc/library/importlib.rst | |
parent | 4dbae881311073eedd6ef290ec206978f530ef98 (diff) | |
download | cpython-a3687f0d6896673689d8dd5c13e113947f66e921.zip cpython-a3687f0d6896673689d8dd5c13e113947f66e921.tar.gz cpython-a3687f0d6896673689d8dd5c13e113947f66e921.tar.bz2 |
Introduce importlib.util.ModuleManager which is a context manager to
handle providing (and cleaning up if needed) the module to be loaded.
A future commit will use the context manager in
Lib/importlib/_bootstrap.py and thus why the code is placed there
instead of in Lib/importlib/util.py.
Diffstat (limited to 'Doc/library/importlib.rst')
-rw-r--r-- | Doc/library/importlib.rst | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index 45fc8ba..753030a 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -789,6 +789,15 @@ an :term:`importer`. .. versionadded:: 3.3 +.. class:: ModuleManager(name) + + A :term:`context manager` which provides the module to load. The module will + either come from :attr:`sys.modules` in the case of reloading or a fresh + module if loading a new module. Proper cleanup of :attr:`sys.modules` occurs + if the module was new and an exception was raised. + + .. versionadded:: 3.4 + .. decorator:: module_for_loader A :term:`decorator` for a :term:`loader` method, @@ -818,6 +827,10 @@ an :term:`importer`. Use of this decorator handles all the details of which module object a loader should initialize as specified by :pep:`302` as best as possible. + .. note:: + :class:`ModuleManager` subsumes the module management aspect of this + decorator. + .. versionchanged:: 3.3 :attr:`__loader__` and :attr:`__package__` are automatically set (when possible). |