mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-97850: Deprecate find_loader
and get_loader
in pkgutil
(GH-98520)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
This commit is contained in:
parent
9f9e001ab2
commit
d6e83fbf30
5 changed files with 43 additions and 18 deletions
|
@ -270,6 +270,10 @@ def get_loader(module_or_name):
|
|||
If the named module is not already imported, its containing package
|
||||
(if any) is imported, in order to establish the package __path__.
|
||||
"""
|
||||
warnings._deprecated("pkgutil.get_loader",
|
||||
f"{warnings._DEPRECATED_MSG}; "
|
||||
"use importlib.util.find_spec() instead",
|
||||
remove=(3, 14))
|
||||
if module_or_name in sys.modules:
|
||||
module_or_name = sys.modules[module_or_name]
|
||||
if module_or_name is None:
|
||||
|
@ -294,6 +298,10 @@ def find_loader(fullname):
|
|||
importlib.util.find_spec that converts most failures to ImportError
|
||||
and only returns the loader rather than the full spec
|
||||
"""
|
||||
warnings._deprecated("pkgutil.find_loader",
|
||||
f"{warnings._DEPRECATED_MSG}; "
|
||||
"use importlib.util.find_spec() instead",
|
||||
remove=(3, 14))
|
||||
if fullname.startswith('.'):
|
||||
msg = "Relative module name {!r} not supported".format(fullname)
|
||||
raise ImportError(msg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue