]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43720: Update import-related stdlib deprecation messages to say they will be...
authorBrett Cannon <brett@python.org>
Sat, 3 Apr 2021 22:31:15 +0000 (15:31 -0700)
committerGitHub <noreply@github.com>
Sat, 3 Apr 2021 22:31:15 +0000 (15:31 -0700)
Lib/imp.py
Lib/importlib/util.py
Lib/pkgutil.py
Lib/test/test_pkgutil.py
Misc/NEWS.d/next/Library/2021-04-03-13-45-51.bpo-43720.FDZ5cZ.rst [new file with mode: 0644]

index 31f8c766381adc3c125fedcc704277b1f6fa7968..e02aaef344c6148b43ef3954689126319504dea9 100644 (file)
@@ -28,7 +28,8 @@ import tokenize
 import types
 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",
               DeprecationWarning, stacklevel=2)
 
index 98a0fa54dfd873eb19a1d03bd30a060549866993..8623c89840c6a24d6a692b149e1ab66881bf0002 100644 (file)
@@ -149,7 +149,8 @@ def set_package(fxn):
     """
     @functools.wraps(fxn)
     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)
         module = fxn(*args, **kwargs)
         if getattr(module, '__package__', None) is None:
@@ -168,7 +169,8 @@ def set_loader(fxn):
     """
     @functools.wraps(fxn)
     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)
         module = fxn(self, *args, **kwargs)
         if getattr(module, '__loader__', None) is None:
@@ -195,7 +197,8 @@ def module_for_loader(fxn):
     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)
     @functools.wraps(fxn)
     def module_for_loader_wrapper(self, fullname, *args, **kwargs):
index 3d7f19f39981de689f861418859e364f5f374211..2c3429856be46d594caabd84d2ee311c92dd6d9a 100644 (file)
@@ -204,7 +204,8 @@ class ImpImporter:
 
     def __init__(self, path=None):
         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)
         _import_imp()
         self.path = path
@@ -271,7 +272,8 @@ class ImpLoader:
     code = source = None
 
     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)
         _import_imp()
         self.file = file
index bf9722a229611de7d4e2bf4a97941ac56ce12911..6e3618f6b0f98b0f2466e4cd98d6ff0a01017587 100644 (file)
@@ -498,7 +498,8 @@ class ImportlibMigrationTests(unittest.TestCase):
 
     def check_deprecated(self):
         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))
 
     def test_importer_deprecated(self):
diff --git a/Misc/NEWS.d/next/Library/2021-04-03-13-45-51.bpo-43720.FDZ5cZ.rst b/Misc/NEWS.d/next/Library/2021-04-03-13-45-51.bpo-43720.FDZ5cZ.rst
new file mode 100644 (file)
index 0000000..d71460f
--- /dev/null
@@ -0,0 +1,2 @@
+Document various stdlib deprecations in imp, pkgutil, and importlib.util for removal in Python
+3.12.