mirror of https://github.com/python/cpython.git
bpo-43720: Update import-related stdlib deprecation messages to say they will be removed in Python 3.12 (GH-25167)
This commit is contained in:
parent
c5354c045c
commit
dc6d3e1e4c
|
@ -28,7 +28,8 @@
|
||||||
import types
|
import types
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
warnings.warn("the imp module is deprecated in favour of importlib; "
|
warnings.warn("the imp module is deprecated in favour of importlib and slated "
|
||||||
|
"for removal in Python 3.12; "
|
||||||
"see the module's documentation for alternative uses",
|
"see the module's documentation for alternative uses",
|
||||||
DeprecationWarning, stacklevel=2)
|
DeprecationWarning, stacklevel=2)
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,8 @@ def set_package(fxn):
|
||||||
"""
|
"""
|
||||||
@functools.wraps(fxn)
|
@functools.wraps(fxn)
|
||||||
def set_package_wrapper(*args, **kwargs):
|
def set_package_wrapper(*args, **kwargs):
|
||||||
warnings.warn('The import system now takes care of this automatically.',
|
warnings.warn('The import system now takes care of this automatically; '
|
||||||
|
'this decorator is slated for removal in Python 3.12',
|
||||||
DeprecationWarning, stacklevel=2)
|
DeprecationWarning, stacklevel=2)
|
||||||
module = fxn(*args, **kwargs)
|
module = fxn(*args, **kwargs)
|
||||||
if getattr(module, '__package__', None) is None:
|
if getattr(module, '__package__', None) is None:
|
||||||
|
@ -168,7 +169,8 @@ def set_loader(fxn):
|
||||||
"""
|
"""
|
||||||
@functools.wraps(fxn)
|
@functools.wraps(fxn)
|
||||||
def set_loader_wrapper(self, *args, **kwargs):
|
def set_loader_wrapper(self, *args, **kwargs):
|
||||||
warnings.warn('The import system now takes care of this automatically.',
|
warnings.warn('The import system now takes care of this automatically; '
|
||||||
|
'this decorator is slated for removal in Python 3.12',
|
||||||
DeprecationWarning, stacklevel=2)
|
DeprecationWarning, stacklevel=2)
|
||||||
module = fxn(self, *args, **kwargs)
|
module = fxn(self, *args, **kwargs)
|
||||||
if getattr(module, '__loader__', None) is None:
|
if getattr(module, '__loader__', None) is None:
|
||||||
|
@ -195,7 +197,8 @@ def module_for_loader(fxn):
|
||||||
the second argument.
|
the second argument.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
warnings.warn('The import system now takes care of this automatically.',
|
warnings.warn('The import system now takes care of this automatically; '
|
||||||
|
'this decorator is slated for removal in Python 3.12',
|
||||||
DeprecationWarning, stacklevel=2)
|
DeprecationWarning, stacklevel=2)
|
||||||
@functools.wraps(fxn)
|
@functools.wraps(fxn)
|
||||||
def module_for_loader_wrapper(self, fullname, *args, **kwargs):
|
def module_for_loader_wrapper(self, fullname, *args, **kwargs):
|
||||||
|
|
|
@ -204,7 +204,8 @@ class ImpImporter:
|
||||||
|
|
||||||
def __init__(self, path=None):
|
def __init__(self, path=None):
|
||||||
global imp
|
global imp
|
||||||
warnings.warn("This emulation is deprecated, use 'importlib' instead",
|
warnings.warn("This emulation is deprecated and slated for removal "
|
||||||
|
"in Python 3.12; use 'importlib' instead",
|
||||||
DeprecationWarning)
|
DeprecationWarning)
|
||||||
_import_imp()
|
_import_imp()
|
||||||
self.path = path
|
self.path = path
|
||||||
|
@ -271,7 +272,8 @@ class ImpLoader:
|
||||||
code = source = None
|
code = source = None
|
||||||
|
|
||||||
def __init__(self, fullname, file, filename, etc):
|
def __init__(self, fullname, file, filename, etc):
|
||||||
warnings.warn("This emulation is deprecated, use 'importlib' instead",
|
warnings.warn("This emulation is deprecated and slated for removal in "
|
||||||
|
"Python 3.12; use 'importlib' instead",
|
||||||
DeprecationWarning)
|
DeprecationWarning)
|
||||||
_import_imp()
|
_import_imp()
|
||||||
self.file = file
|
self.file = file
|
||||||
|
|
|
@ -498,7 +498,8 @@ class ImportlibMigrationTests(unittest.TestCase):
|
||||||
|
|
||||||
def check_deprecated(self):
|
def check_deprecated(self):
|
||||||
return check_warnings(
|
return check_warnings(
|
||||||
("This emulation is deprecated, use 'importlib' instead",
|
("This emulation is deprecated and slated for removal in "
|
||||||
|
"Python 3.12; use 'importlib' instead",
|
||||||
DeprecationWarning))
|
DeprecationWarning))
|
||||||
|
|
||||||
def test_importer_deprecated(self):
|
def test_importer_deprecated(self):
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Document various stdlib deprecations in imp, pkgutil, and importlib.util for removal in Python
|
||||||
|
3.12.
|
Loading…
Reference in New Issue