@@ -347,13 +347,16 @@ ABC hierarchy::
347347
348348 .. method :: create_module(spec)
349349
350- An optional method that returns the module object to use when
351- importing a module. create_module() may also return ``None ``,
352- indicating that the default module creation should take place
353- instead.
350+ A method that returns the module object to use when
351+ importing a module. This method may return ``None ``,
352+ indicating that default module creation semantics should take place.
354353
355354 .. versionadded :: 3.4
356355
356+ .. versionchanged :: 3.5
357+ Starting in Python 3.6, this method will not be optional when
358+ :meth: `exec_module ` is defined.
359+
357360 .. method :: exec_module(module)
358361
359362 An abstract method that executes the module in its own namespace
@@ -417,7 +420,7 @@ ABC hierarchy::
417420
418421 .. deprecated :: 3.4
419422 The recommended API for loading a module is :meth: `exec_module `
420- (and optionally :meth: `create_module `). Loaders should implement
423+ (and :meth: `create_module `). Loaders should implement
421424 it instead of load_module(). The import machinery takes care of
422425 all the other responsibilities of load_module() when exec_module()
423426 is implemented.
@@ -1136,9 +1139,9 @@ an :term:`importer`.
11361139
11371140.. function :: module_from_spec(spec)
11381141
1139- Create a new module based on **spec **.
1142+ Create a new module based on **spec ** and `` spec.loader.create_module() `` .
11401143
1141- If the module object is from ``spec.loader.create_module() ``, then any
1144+ If ``spec.loader.create_module() `` does not return `` None ``, then any
11421145 pre-existing attributes will not be reset. Also, no :exc: `AttributeError `
11431146 will be raised if triggered while accessing **spec ** or setting an attribute
11441147 on the module.
@@ -1234,9 +1237,10 @@ an :term:`importer`.
12341237 module has an attribute accessed.
12351238
12361239 This class **only ** works with loaders that define
1237- :meth: `importlib.abc.Loader.exec_module ` as control over what module type
1238- is used for the module is required. For the same reasons, the loader
1239- **cannot ** define :meth: `importlib.abc.Loader.create_module `. Finally,
1240+ :meth: `~importlib.abc.Loader.exec_module ` as control over what module type
1241+ is used for the module is required. For those same reasons, the loader's
1242+ :meth: `~importlib.abc.Loader.create_module ` method will be ignored (i.e., the
1243+ loader's method should only return ``None ``). Finally,
12401244 modules which substitute the object placed into :attr: `sys.modules ` will
12411245 not work as there is no way to properly replace the module references
12421246 throughout the interpreter safely; :exc: `ValueError ` is raised if such a
0 commit comments