summaryrefslogtreecommitdiffstats
path: root/Doc/reference/import.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/reference/import.rst')
-rw-r--r--Doc/reference/import.rst20
1 files changed, 11 insertions, 9 deletions
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst
index eb497a1..b587fc9 100644
--- a/Doc/reference/import.rst
+++ b/Doc/reference/import.rst
@@ -373,16 +373,18 @@ Loaders must satisfy the following requirements:
* The ``__loader__`` attribute must be set to the loader object that loaded
the module. This is mostly for introspection and reloading, but can be
used for additional loader-specific functionality, for example getting
- data associated with a loader.
+ data associated with a loader. If the attribute is missing or set to ``None``
+ then the import machinery will automatically set it **after** the module has
+ been imported.
- * The module's ``__package__`` attribute should be set. Its value must be a
+ * The module's ``__package__`` attribute must be set. Its value must be a
string, but it can be the same value as its ``__name__``. If the attribute
is set to ``None`` or is missing, the import system will fill it in with a
- more appropriate value. When the module is a package, its ``__package__``
- value should be set to its ``__name__``. When the module is not a package,
- ``__package__`` should be set to the empty string for top-level modules, or
- for submodules, to the parent package's name. See :pep:`366` for further
- details.
+ more appropriate value **after** the module has been imported.
+ When the module is a package, its ``__package__`` value should be set to its
+ ``__name__``. When the module is not a package, ``__package__`` should be
+ set to the empty string for top-level modules, or for submodules, to the
+ parent package's name. See :pep:`366` for further details.
This attribute is used instead of ``__name__`` to calculate explicit
relative imports for main modules, as defined in :pep:`366`.
@@ -425,8 +427,8 @@ Here are the exact rules used:
* If the module has a ``__file__`` attribute, this is used as part of the
module's repr.
- * If the module has no ``__file__`` but does have a ``__loader__``, then the
- loader's repr is used as part of the module's repr.
+ * If the module has no ``__file__`` but does have a ``__loader__`` that is not
+ ``None``, then the loader's repr is used as part of the module's repr.
* Otherwise, just use the module's ``__name__`` in the repr.