Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56b4ca7

Browse files
committed
Issue #16489: Make it clearer that importlib.find_loader() requires
the user to import any parent packages.
1 parent 4a42ec5 commit 56b4ca7

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

Doc/library/importlib.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ Functions
9494
:exc:`ValueError` is raised). Otherwise a search using :attr:`sys.meta_path`
9595
is done. ``None`` is returned if no loader is found.
9696

97-
A dotted name does not have its parent's implicitly imported. If that is
98-
desired (although not nessarily required to find the loader, it will most
99-
likely be needed if the loader actually is used to load the module), then
100-
you will have to import the packages containing the module prior to calling
101-
this function.
97+
A dotted name does not have its parent's implicitly imported as that requires
98+
loading them and that may not be desired. To properly import a submodule you
99+
will need to import all parent packages of the submodule and use the correct
100+
argument to *path*.
102101

103102
.. function:: invalidate_caches()
104103

Lib/importlib/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def find_loader(name, path=None):
5555
value of 'path' given to the finders. None is returned if no loader could
5656
be found.
5757
58-
Dotted names do not have their parent packages implicitly imported.
58+
Dotted names do not have their parent packages implicitly imported. You will
59+
most likely need to explicitly import all parent packages in the proper
60+
order for a submodule to get the correct loader.
5961
6062
"""
6163
try:

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ Tools/Demos
271271
Documentation
272272
-------------
273273

274+
- Issue #16489: Make it clearer that importlib.find_loader() requires any and
275+
all packages to be separately imported.
276+
274277
- Issue #16400: Update the description of which versions of a given package
275278
PyPI displays.
276279

0 commit comments

Comments
 (0)