diff options
author | Brett Cannon <brett@python.org> | 2013-03-13 17:41:36 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-03-13 17:41:36 (GMT) |
commit | 4802becb160d76c2e0993ce7e8abbbe23667f91f (patch) | |
tree | 47c56787e702b1b15bc2d3fee5de3e9730aa9a57 /Doc/reference | |
parent | aa73a1c9c9c149002f98dbf6fdd12eb3d41225ee (diff) | |
download | cpython-4802becb160d76c2e0993ce7e8abbbe23667f91f.zip cpython-4802becb160d76c2e0993ce7e8abbbe23667f91f.tar.gz cpython-4802becb160d76c2e0993ce7e8abbbe23667f91f.tar.bz2 |
Issue #17117: Have both import itself and importlib.util.set_loader()
set __loader__ on a module when set to None.
Thanks to Gökcen Eraslan for the fix.
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/import.rst | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index ef0235d..ee1538f 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -369,16 +369,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`. |