Commit 191e3138 authored by Barry Warsaw's avatar Barry Warsaw Committed by GitHub

bpo-31799: Make module.__spec__ more discoverable (#4010)

bpo-31799: Make module.__spec__ more discoverable
parent 6cfa927c
...@@ -1048,7 +1048,15 @@ find and load modules. ...@@ -1048,7 +1048,15 @@ find and load modules.
.. class:: ModuleSpec(name, loader, *, origin=None, loader_state=None, is_package=None) .. class:: ModuleSpec(name, loader, *, origin=None, loader_state=None, is_package=None)
A specification for a module's import-system-related state. A specification for a module's import-system-related state. This is
typically exposed as the module's ``__spec__`` attribute. In the
descriptions below, the names in parentheses give the corresponding
attribute available directly on the module object.
E.g. ``module.__spec__.origin == module.__file__``. Note however that
while the *values* are usually equivalent, they can differ since there is
no synchronization between the two objects. Thus it is possible to update
the module's ``__path__`` at runtime, and this will not be automatically
reflected in ``__spec__.submodule_search_locations``.
.. versionadded:: 3.4 .. versionadded:: 3.4
......
...@@ -519,8 +519,9 @@ and the loader that executes it. Most importantly, it allows the ...@@ -519,8 +519,9 @@ and the loader that executes it. Most importantly, it allows the
import machinery to perform the boilerplate operations of loading, import machinery to perform the boilerplate operations of loading,
whereas without a module spec the loader had that responsibility. whereas without a module spec the loader had that responsibility.
See :class:`~importlib.machinery.ModuleSpec` for more specifics on what The module's spec is exposed as the ``__spec__`` attribute on a module object.
information a module's spec may hold. See :class:`~importlib.machinery.ModuleSpec` for details on the contents of
the module spec.
.. versionadded:: 3.4 .. versionadded:: 3.4
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment