mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Issue #15056: imp.cache_from_source() and source_from_cache() raise
NotimplementedError when sys.implementation.cache_tag is None. Thanks to Pranav Ravichandran for taking an initial stab at the patch.
This commit is contained in:
parent
bf7eab077f
commit
19a2f5961c
6 changed files with 3875 additions and 3802 deletions
|
@ -180,14 +180,19 @@ file paths.
|
|||
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`). The returned path will end in ``.pyc`` when
|
||||
``__debug__`` is True or ``.pyo`` for an optimized Python
|
||||
: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.
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
If :attr:`sys.implementation.cache_tag` is ``None``, then
|
||||
:exc:`NotImplementedError` is raised.
|
||||
|
||||
|
||||
.. function:: source_from_cache(path)
|
||||
|
||||
|
@ -195,7 +200,13 @@ file paths.
|
|||
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.
|
||||
to :pep:`3147` format, a ``ValueError`` is raised. If
|
||||
:attr:`sys.implementation.cache_tag` is not defined,
|
||||
:exc:`NotImplementedError` is raised.
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
Raise :exc:`NotImplementedError` when
|
||||
:attr:`sys.implementation.cache_tag` is not defined.
|
||||
|
||||
|
||||
.. function:: get_tag()
|
||||
|
@ -203,6 +214,10 @@ file paths.
|
|||
Return the :pep:`3147` magic tag string matching this version of Python's
|
||||
magic number, as returned by :func:`get_magic`.
|
||||
|
||||
.. note::
|
||||
You may use :attr:`sys.implementation.cache_tag` directly starting
|
||||
in Python 3.3.
|
||||
|
||||
|
||||
The following functions help interact with the import system's internal
|
||||
locking mechanism. Locking semantics of imports are an implementation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue