summaryrefslogtreecommitdiffstats
path: root/Doc/library/importlib.rst
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-11-18 15:03:31 (GMT)
committerBrett Cannon <brett@python.org>2012-11-18 15:03:31 (GMT)
commit5650e4f41cc65fae44e44702919df592f15211f3 (patch)
tree97f15ed45c4bdcf40670b50a9c93314a5e00187d /Doc/library/importlib.rst
parent195ad6ce052bfdda8f47ffbf14becb95253bafc6 (diff)
downloadcpython-5650e4f41cc65fae44e44702919df592f15211f3.zip
cpython-5650e4f41cc65fae44e44702919df592f15211f3.tar.gz
cpython-5650e4f41cc65fae44e44702919df592f15211f3.tar.bz2
Issue #15627: Add the compile_source() method to
importlib.abc.SourceLoader. This provides an easy hook into the import system to allow for source transformations, AST optimizations, etc.
Diffstat (limited to 'Doc/library/importlib.rst')
-rw-r--r--Doc/library/importlib.rst17
1 files changed, 15 insertions, 2 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 0369570..6c9c6b3 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -364,10 +364,12 @@ ABC hierarchy::
* :meth:`ResourceLoader.get_data`
* :meth:`ExecutionLoader.get_filename`
Should only return the path to the source file; sourceless
- loading is not supported.
+ loading is not supported (see :class:`SourcelessLoader` if that
+ functionality is required)
The abstract methods defined by this class are to add optional bytecode
- file support. Not implementing these optional methods causes the loader to
+ file support. Not implementing these optional methods (or causing them to
+ raise :exc:`NotImplementedError`) causes the loader to
only work with source code. Implementing the methods allows the loader to
work with source *and* bytecode files; it does not allow for *sourceless*
loading where only bytecode is provided. Bytecode files are an
@@ -407,6 +409,17 @@ ABC hierarchy::
When writing to the path fails because the path is read-only
(:attr:`errno.EACCES`), do not propagate the exception.
+ .. method:: compile_source(data, path)
+
+ Create a code object from Python source.
+
+ The *data* argument can be whatever the :func:`compile` function
+ supports (i.e. string or bytes). The *path* argument should be
+ the "path" to where the source code originated from, which can be an
+ abstract concept (e.g. location in a zip file).
+
+ .. versionadded:: 3.4
+
.. method:: get_code(fullname)
Concrete implementation of :meth:`InspectLoader.get_code`.