Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13232)

Unified Diff: Doc/library/importlib.rst

Issue 23014: Don't have importlib.abc.Loader.create_module() be optional
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Doc/reference/import.rst » ('j') | Doc/reference/import.rst » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Doc/library/importlib.rst Fri Dec 12 12:00:02 2014 -0500
+++ b/Doc/library/importlib.rst Fri Dec 12 12:23:43 2014 -0500
@@ -347,13 +347,16 @@
.. method:: create_module(spec)
- An optional method that returns the module object to use when
- importing a module. create_module() may also return ``None``,
- indicating that the default module creation should take place
- instead.
+ A method that returns the module object to use when
+ importing a module. This method may return ``None``,
+ indicating that default module creation semantics should take place.
.. versionadded:: 3.4
+ .. versionchanged:: 3.5
+ Starting in Python 3.6, this method wil not optional when
berkerpeksag 2014/12/12 20:07:45 wil -> will
eric.snow 2014/12/16 03:42:16 s/wil not/will not be/
brett.cannon 2015/01/09 17:28:56 Done.
brett.cannon 2015/01/09 17:28:56 Done.
+ :meth:`exec_module` is defined.
+
.. method:: exec_module(module)
An abstract method that executes the module in its own namespace
@@ -417,7 +420,7 @@
.. deprecated:: 3.4
The recommended API for loading a module is :meth:`exec_module`
- (and optionally :meth:`create_module`). Loaders should implement
+ (and :meth:`create_module`). Loaders should implement
it instead of load_module(). The import machinery takes care of
all the other responsibilities of load_module() when exec_module()
is implemented.
@@ -1136,9 +1139,9 @@
.. function:: module_from_spec(spec)
- Create a new module based on **spec**.
+ Create a new module based on **spec** and ``spec.loader.create_module()``.
- If the module object is from ``spec.loader.create_module()``, then any
+ If ``spec.loader.create_module()`` does not return None, then any
berkerpeksag 2014/12/12 20:07:45 None -> ``None``
brett.cannon 2015/01/09 17:28:56 Done.
pre-existing attributes will not be reset. Also, no :exc:`AttributeError`
will be raised if triggered while accessing **spec** or setting an attribute
on the module.
@@ -1234,9 +1237,10 @@
module has an attribute accessed.
This class **only** works with loaders that define
- :meth:`importlib.abc.Loader.exec_module` as control over what module type
- is used for the module is required. For the same reasons, the loader
- **cannot** define :meth:`importlib.abc.Loader.create_module`. Finally,
+ :meth:`~importlib.abc.Loader.exec_module` as control over what module type
+ is used for the module is required. For those same reasons, the loader's
+ :meth:`~importlib.abc.Loader.create_module` method will be ignored (i.e., the
+ loader's method should only return ``None``). Finally,
modules which substitute the object placed into :attr:`sys.modules` will
not work as there is no way to properly replace the module references
throughout the interpreter safely; :exc:`ValueError` is raised if such a
« no previous file with comments | « no previous file | Doc/reference/import.rst » ('j') | Doc/reference/import.rst » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+