mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #14938: importlib.abc.SourceLoader.is_package() now takes the
module name into consideration when determining whether a module is a package or not. This prevents importing a module's __init__ module directly and having it considered a package, which can lead to duplicate sub-modules. Thanks to Ronan Lamy for reporting the bug.
This commit is contained in:
parent
0450c9ed52
commit
ea0b823940
4 changed files with 14 additions and 5 deletions
|
|
@ -351,8 +351,10 @@ are also provided to help in implementing the core ABCs.
|
|||
.. method:: is_package(self, fullname)
|
||||
|
||||
Concrete implementation of :meth:`InspectLoader.is_package`. A module
|
||||
is determined to be a package if its file path is a file named
|
||||
``__init__`` when the file extension is removed.
|
||||
is determined to be a package if its file path (as provided by
|
||||
:meth:`ExecutionLoader.get_filename`) is a file named
|
||||
``__init__`` when the file extension is removed **and** the module name
|
||||
itself does not end in ``__init__``.
|
||||
|
||||
|
||||
.. class:: PyLoader
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue