diff options
author | Brett Cannon <brett@python.org> | 2013-06-15 02:26:30 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-06-15 02:26:30 (GMT) |
commit | a3c96154d2a8d3dd0023b927a99b485e574c9922 (patch) | |
tree | bdbc356425aa360bbbbdc2d816147a8940ef1723 /Doc/library | |
parent | 15e489f7c54a3ca5e631b7bfaf26e85daf0547bb (diff) | |
download | cpython-a3c96154d2a8d3dd0023b927a99b485e574c9922.zip cpython-a3c96154d2a8d3dd0023b927a99b485e574c9922.tar.gz cpython-a3c96154d2a8d3dd0023b927a99b485e574c9922.tar.bz2 |
Issue #17907: touch up the code for imp.new_module().
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/imp.rst | 6 | ||||
-rw-r--r-- | Doc/library/importlib.rst | 30 |
2 files changed, 36 insertions, 0 deletions
diff --git a/Doc/library/imp.rst b/Doc/library/imp.rst index c6a07ca..ab79be3 100644 --- a/Doc/library/imp.rst +++ b/Doc/library/imp.rst @@ -205,6 +205,9 @@ file paths. If :attr:`sys.implementation.cache_tag` is ``None``, then :exc:`NotImplementedError` is raised. + .. deprecated:: 3.4 + Use :func:`importlib.util.cache_from_source` instead. + .. function:: source_from_cache(path) @@ -220,6 +223,9 @@ file paths. Raise :exc:`NotImplementedError` when :attr:`sys.implementation.cache_tag` is not defined. + .. deprecated:: 3.4 + Use :func:`importlib.util.source_from_cache` instead. + .. function:: get_tag() diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index e9b7717..d7ed14b 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -886,6 +886,36 @@ an :term:`importer`. .. versionadded:: 3.4 +.. function:: cache_from_source(path, debug_override=None) + + Return the :pep:`3147` path to the byte-compiled file associated with the + source *path*. For example, if *path* is ``/foo/bar/baz.py`` the return + value would be ``/foo/bar/__pycache__/baz.cpython-32.pyc`` for Python 3.2. + The ``cpython-32`` string comes from the current magic tag (see + :func:`get_tag`; if :attr:`sys.implementation.cache_tag` is not defined then + :exc:`NotImplementedError` will be raised). The returned path will end in + ``.pyc`` when ``__debug__`` is True or ``.pyo`` for an optimized Python + (i.e. ``__debug__`` is False). By passing in True or False for + *debug_override* you can override the system's value for ``__debug__`` for + extension selection. + + *path* need not exist. + + .. versionadded:: 3.4 + + +.. function:: source_from_cache(path) + + Given the *path* to a :pep:`3147` file name, return the associated source code + file path. For example, if *path* is + ``/foo/bar/__pycache__/baz.cpython-32.pyc`` the returned path would be + ``/foo/bar/baz.py``. *path* need not exist, however if it does not conform + to :pep:`3147` format, a ``ValueError`` is raised. If + :attr:`sys.implementation.cache_tag` is not defined, + :exc:`NotImplementedError` is raised. + + .. versionadded:: 3.4 + .. function:: resolve_name(name, package) Resolve a relative module name to an absolute one. |