diff options
author | Brett Cannon <brett@python.org> | 2020-11-13 23:14:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 23:14:58 (GMT) |
commit | d2e94bb0848e04a90efa51be401f0ce8a9e252f2 (patch) | |
tree | 241cec2ab4a3037fee4406acc2cd502db1d8bf1c /Doc | |
parent | 9b6934230c35e24d8582ea8c58456fa8eab72ae2 (diff) | |
download | cpython-d2e94bb0848e04a90efa51be401f0ce8a9e252f2.zip cpython-d2e94bb0848e04a90efa51be401f0ce8a9e252f2.tar.gz cpython-d2e94bb0848e04a90efa51be401f0ce8a9e252f2.tar.bz2 |
bpo-42131: Add PEP 451-related methods to zipimport (GH-23187)
Specifically, find_spec(), create_module(), and exec_module().
Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/zipimport.rst | 46 | ||||
-rw-r--r-- | Doc/whatsnew/3.10.rst | 7 |
2 files changed, 50 insertions, 3 deletions
diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst index 8ac3fb1..8d579f2 100644 --- a/Doc/library/zipimport.rst +++ b/Doc/library/zipimport.rst @@ -44,8 +44,9 @@ doesn't contain :file:`.pyc` files, importing may be rather slow. follows the specification in :pep:`273`, but uses an implementation written by Just van Rossum that uses the import hooks described in :pep:`302`. - :pep:`302` - New Import Hooks - The PEP to add the import hooks that help this module work. + :mod:`importlib` - The implementation of the import machinery + Package providing the relevant protocols for all importers to + implement. This module defines an exception: @@ -73,7 +74,31 @@ zipimporter Objects :exc:`ZipImportError` is raised if *archivepath* doesn't point to a valid ZIP archive. - .. method:: find_module(fullname[, path]) + .. method:: create_module(spec) + + Implementation of :meth:`importlib.abc.Loader.create_module` that returns + :const:`None` to explicitly request the default semantics. + + .. versionadded:: 3.10 + + + .. method:: exec_module(module) + + Implementation of :meth:`importlib.abc.Loader.exec_module`. + + .. versionadded:: 3.10 + + + .. method:: find_loader(fullname, path=None) + + An implementation of :meth:`importlib.abc.PathEntryFinder.find_loader`. + + .. deprecated:: 3.10 + + Use :meth:`find_spec` instead. + + + .. method:: find_module(fullname, path=None) Search for a module specified by *fullname*. *fullname* must be the fully qualified (dotted) module name. It returns the zipimporter instance itself @@ -81,6 +106,17 @@ zipimporter Objects *path* argument is ignored---it's there for compatibility with the importer protocol. + .. deprecated:: 3.10 + + Use :meth:`find_spec` instead. + + + .. method:: find_spec(fullname, target=None) + + An implementation of :meth:`importlib.abc.PathEntryFinder.find_spec`. + + .. versionadded:: 3.10 + .. method:: get_code(fullname) @@ -126,6 +162,10 @@ zipimporter Objects qualified (dotted) module name. It returns the imported module, or raises :exc:`ZipImportError` if it wasn't found. + .. deprecated:: 3.10 + + Use :meth:`exec_module` instead. + .. attribute:: archive diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index c1ce5f3..b8e6843 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -303,6 +303,13 @@ Add a :class:`~xml.sax.handler.LexicalHandler` class to the :mod:`xml.sax.handler` module. (Contributed by Jonathan Gossage and Zackery Spytz in :issue:`35018`.) +zipimport +--------- +Add methods related to :pep:`451`: :meth:`~zipimport.zipimporter.find_spec`, +:meth:`zipimport.zipimporter.create_module`, and +:meth:`zipimport.zipimporter.exec_module`. +(Contributed by Brett Cannon in :issue:`42131`. + Optimizations ============= |