From f3be051e3fe1938760999f9b341fba70d71d5c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Ogam?= Date: Fri, 9 Aug 2019 10:01:06 +0200 Subject: [PATCH 1/6] Update importlib.rst --- Doc/library/importlib.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index 8be6172d4c76e9..2b45b618e3f208 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -435,8 +435,9 @@ ABC hierarchy:: package. This attribute is not set on modules. - :attr:`__package__` - The parent package for the module/package. If the module is - top-level then it has a value of the empty string. The + The fully-qualified name of the package under which the module was + loaded as a submodule (or the empty string for top-level modules). + For packages, it is the same as :attr:`__name__`. The :func:`importlib.util.module_for_loader` decorator can handle the details for :attr:`__package__`. @@ -1303,8 +1304,8 @@ find and load modules. (``__loader__``) - The loader to use for loading. For namespace packages this should be - set to ``None``. + The :class:`Loader ` that should be used when loading + the module. Finders should always set this. .. attribute:: origin @@ -1337,8 +1338,9 @@ find and load modules. (``__package__``) - (Read-only) Fully-qualified name of the package to which the module - belongs as a submodule (or ``None``). + (Read-only) The fully-qualified name of the package under which the module + should be loaded as a submodule (or the empty string for top-level modules). + For packages, it is the same as :attr:`__name__`. .. attribute:: has_location From ed4c2e0dd29fd6d740a530537b950f458cdbb9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Ogam?= Date: Fri, 9 Aug 2019 11:58:24 +0200 Subject: [PATCH 2/6] Update import.rst --- Doc/reference/import.rst | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index 0228bfb7e984c5..95421c7957e748 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -855,7 +855,7 @@ 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 +:term:`portion`, the path entry finder sets "origin" on the spec to ``None`` and "submodule_search_locations" to a list containing the portion. @@ -873,18 +873,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, From 583eb625c44d4a87866f60653d1c1602bf12937c Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 21 Oct 2020 11:39:40 -0700 Subject: [PATCH 3/6] Use a term link instead of a class link Co-authored-by: Kyle Stanley --- Doc/library/importlib.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index 2b45b618e3f208..ff1f9c23929091 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -1304,7 +1304,7 @@ find and load modules. (``__loader__``) - The :class:`Loader ` that should be used when loading + The :term:`Loader` that should be used when loading the module. Finders should always set this. .. attribute:: origin From 3c10dfb42d6006c904cf30b30d39b8756f510fbf Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 21 Oct 2020 11:40:36 -0700 Subject: [PATCH 4/6] Add a term link for "Finders" Co-authored-by: Kyle Stanley --- Doc/library/importlib.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index ff1f9c23929091..c6db2fdc6853cd 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -1305,7 +1305,7 @@ find and load modules. (``__loader__``) The :term:`Loader` that should be used when loading - the module. Finders should always set this. + the module. :term:`Finders ` should always set this. .. attribute:: origin From 6bd63be5e7662e0837b3771890a6fc0966709869 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 21 Oct 2020 13:53:49 -0700 Subject: [PATCH 5/6] Fix the reference for the "loader" term --- Doc/library/importlib.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index c4aa719e2cd394..45b62aec9ef537 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -1348,7 +1348,7 @@ find and load modules. (``__loader__``) - The :term:`Loader` that should be used when loading + The :term:`Loader ` that should be used when loading the module. :term:`Finders ` should always set this. .. attribute:: origin From 8f6192a3b2f82ca283c860af9ae75d538f5a375e Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 21 Oct 2020 13:59:12 -0700 Subject: [PATCH 6/6] Fix trailing whitespace --- Doc/reference/import.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index b327f47f0dfb83..c5952426fdcf8d 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -857,7 +857,7 @@ 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 "submodule_search_locations" to +:term:`portion`, the path entry finder sets "submodule_search_locations" to a list containing the portion. .. versionchanged:: 3.4