mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-35673: Add a public alias for namespace package __loader__ attribute (#29049)
Rename namespace package __loader__ class to be public. Make the old name, i.e. _NamespaceLoader, an alias for the public name, for backward compatibility.
This commit is contained in:
parent
6270d3eeaf
commit
876fc7fcec
7 changed files with 42 additions and 6 deletions
|
@ -1394,6 +1394,24 @@ find and load modules.
|
|||
.. versionadded:: 3.4
|
||||
|
||||
|
||||
.. class:: NamespaceLoader(name, path, path_finder):
|
||||
|
||||
A concrete implementation of :class:`importlib.abc.InspectLoader` for
|
||||
namespace packages. This is an alias for a private class and is only made
|
||||
public for introspecting the ``__loader__`` attribute on namespace
|
||||
packages::
|
||||
|
||||
>>> from importlib.machinery import NamespaceLoader
|
||||
>>> import my_namespace
|
||||
>>> isinstance(my_namespace.__loader__, NamespaceLoader)
|
||||
True
|
||||
>>> import importlib.abc
|
||||
>>> isinstance(my_namespace.__loader__, importlib.abc.Loader)
|
||||
True
|
||||
|
||||
.. versionadded:: 3.11
|
||||
|
||||
|
||||
.. class:: ModuleSpec(name, loader, *, origin=None, loader_state=None, is_package=None)
|
||||
|
||||
A specification for a module's import-system-related state. This is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue