Issue #20383: Introduce importlib.util.module_from_spec().

Along the way, dismantle importlib._bootstrap._SpecMethods as it was
no longer relevant and constructing the new function required
partially dismantling the class anyway.
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 0adeefb..0ca8490 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -1129,6 +1129,21 @@
 
    .. versionadded:: 3.4
 
+.. function:: module_from_spec(spec)
+
+   Create a new module based on **spec**.
+
+   If the module object is from ``spec.loader.create_module()``, then any
+   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.
+
+   This function is preferred over using :class:`types.ModuleType` to create a
+   new module as **spec** is used to set as many import-controlled attributes on
+   the module as possible.
+
+   .. versionadded:: 3.5
+
 .. decorator:: module_for_loader
 
     A :term:`decorator` for :meth:`importlib.abc.Loader.load_module`
diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index abdb939..34fffe6 100644
--- a/Doc/library/types.rst
+++ b/Doc/library/types.rst
@@ -115,6 +115,10 @@
    The type of :term:`modules <module>`. Constructor takes the name of the
    module to be created and optionally its :term:`docstring`.
 
+   .. note::
+      Use :func:`importlib.util.module_from_spec` to create a new module if you
+      wish to set the various import-controlled attributes.
+
    .. attribute:: __doc__
 
       The :term:`docstring` of the module. Defaults to ``None``.