summaryrefslogtreecommitdiffstats
path: root/Doc/reference
diff options
context:
space:
mode:
authorGéry Ogam <gery.ogam@gmail.com>2020-10-21 21:17:35 (GMT)
committerGitHub <noreply@github.com>2020-10-21 21:17:35 (GMT)
commit27f1bd8787d24ac53cc3dc6ea5eb00b8a3499839 (patch)
treedcab2a276f5f5b44190f2f7bb865d2e891809d2d /Doc/reference
parentf8b1ccd63c94bcde1c15d56d24add89861b6ceee (diff)
downloadcpython-27f1bd8787d24ac53cc3dc6ea5eb00b8a3499839.zip
cpython-27f1bd8787d24ac53cc3dc6ea5eb00b8a3499839.tar.gz
cpython-27f1bd8787d24ac53cc3dc6ea5eb00b8a3499839.tar.bz2
bpo-35181: Correct importlib documentation for some module attributes (GH-15190)
@ericsnowcurrently This PR will change the following: In the library documentation importlib.rst: - `module.__package__` can be `module.__name__` for packages; - `spec.parent` can be `spec.__name__` for packages; - `spec.loader` is not `None` for namespaces packages. In the language documentation import.rst: - `spec.loader` is not `None` for namespace packages. Automerge-Triggered-By: GH:warsaw
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/import.rst18
1 files changed, 3 insertions, 15 deletions
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst
index 213b314..c595242 100644
--- a/Doc/reference/import.rst
+++ b/Doc/reference/import.rst
@@ -857,9 +857,8 @@ module. ``find_spec()`` returns a fully populated spec for the module.
This spec will always have "loader" set (with one exception).
To indicate to the import machinery that the spec represents a namespace
-:term:`portion`, the path entry finder sets "loader" on the spec to
-``None`` and "submodule_search_locations" to a list containing the
-portion.
+:term:`portion`, the path entry finder sets "submodule_search_locations" to
+a list containing the portion.
.. versionchanged:: 3.4
:meth:`~importlib.abc.PathEntryFinder.find_spec` replaced
@@ -875,18 +874,7 @@ portion.
:meth:`~importlib.abc.PathEntryFinder.find_loader` takes one argument, the
fully qualified name of the module being imported. ``find_loader()``
returns a 2-tuple where the first item is the loader and the second item
- is a namespace :term:`portion`. When the first item (i.e. the loader) is
- ``None``, this means that while the path entry finder does not have a
- loader for the named module, it knows that the path entry contributes to
- a namespace portion for the named module. This will almost always be the
- case where Python is asked to import a namespace package that has no
- physical presence on the file system. When a path entry finder returns
- ``None`` for the loader, the second item of the 2-tuple return value must
- be a sequence, although it can be empty.
-
- If ``find_loader()`` returns a non-``None`` loader value, the portion is
- ignored and the loader is returned from the path based finder, terminating
- the search through the path entries.
+ is a namespace :term:`portion`.
For backwards compatibility with other implementations of the import
protocol, many path entry finders also support the same,