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

Unified Diff: Doc/reference/import.rst

Issue 23014: Don't have importlib.abc.Loader.create_module() be optional
Patch Set: Created 4 years, 10 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
--- a/Doc/reference/import.rst Fri Dec 12 12:00:02 2014 -0500
+++ b/Doc/reference/import.rst Fri Dec 12 12:23:43 2014 -0500
@@ -339,6 +339,7 @@
module = None
if spec.loader is not None and hasattr(spec.loader, 'create_module'):
+ # It is assumed 'exec_module' will also be defined on the loader.
module = spec.loader.create_module(spec)
if module is None:
module = ModuleType(spec.name)
@@ -427,7 +428,7 @@
by implementing a :meth:`~importlib.abc.Loader.create_module` method.
It takes one argument, the module spec, and returns the new module object
to use during loading. ``create_module()`` does not need to set any attributes
-on the module object. If the loader does not define ``create_module()``, the
+on the module object. If the method returns ``None``, the
import machinery will create the new module itself.
.. versionadded:: 3.4
@@ -462,6 +463,11 @@
module(s), and only if the loader itself has loaded the module(s)
explicitly.
+.. versionchanged:: 3.5
+ A :class:`DeprecationWarning` is raised when ``exec_module()`` is defined but
berkerpeksag 2014/12/12 20:07:45 Identation should be 3 space.
berkerpeksag 2014/12/12 20:07:45 :exc:`DeprecationWarning`
brett.cannon 2015/01/09 17:28:56 Done.
brett.cannon 2015/01/09 17:28:56 Done.
+ ``create_module()`` is not. Starting in Python 3.6 it will be an error to not
+ define ``create_module()`` on a loader attached to a ModuleSpec.
+
Module spec
-----------

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