]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-121279: Re-add prematurely removed import warnings to importlib.abc (#121281)
authorMiro Hrončok <miro@hroncok.cz>
Wed, 3 Jul 2024 09:06:20 +0000 (11:06 +0200)
committerGitHub <noreply@github.com>
Wed, 3 Jul 2024 09:06:20 +0000 (11:06 +0200)
Fixup for 51724620e868512bbedb1547aca441bcd27bbe0c

Fixes https://github.com/python/cpython/issues/121279

Lib/importlib/abc.py
Lib/test/test_importlib/test_abc.py
Misc/NEWS.d/next/Library/2024-07-02-19-36-54.gh-issue-121279.BltDo9.rst [new file with mode: 0644]

index 16b96266b51be01dccb4a765b156308dc3e8bd24..37fef357fe2c0c76e818fff82b71cf9f0def317d 100644 (file)
@@ -13,6 +13,7 @@ except ImportError:
     _frozen_importlib_external = _bootstrap_external
 from ._abc import Loader
 import abc
+import warnings
 
 from .resources import abc as _resources_abc
 
index 603125f6d926f672f0e0fa1c831bf99fc2d83d6e..479039055ca75ff42de514a31050fbf33992ae87 100644 (file)
@@ -913,5 +913,27 @@ class SourceLoaderGetSourceTests:
                          SourceOnlyLoaderMock=SPLIT_SOL)
 
 
+class DeprecatedAttrsTests:
+
+    """Test the deprecated attributes can be accessed."""
+
+    def test_deprecated_attr_ResourceReader(self):
+        with self.assertWarns(DeprecationWarning):
+            self.abc.ResourceReader
+
+    def test_deprecated_attr_Traversable(self):
+        with self.assertWarns(DeprecationWarning):
+            self.abc.Traversable
+
+    def test_deprecated_attr_TraversableResources(self):
+        with self.assertWarns(DeprecationWarning):
+            self.abc.TraversableResources
+
+
+(Frozen_DeprecatedAttrsTests,
+ Source_DeprecatedAttrsTests
+ ) = test_util.test_both(DeprecatedAttrsTests, abc=abc)
+
+
 if __name__ == '__main__':
     unittest.main()
diff --git a/Misc/NEWS.d/next/Library/2024-07-02-19-36-54.gh-issue-121279.BltDo9.rst b/Misc/NEWS.d/next/Library/2024-07-02-19-36-54.gh-issue-121279.BltDo9.rst
new file mode 100644 (file)
index 0000000..709a378
--- /dev/null
@@ -0,0 +1,2 @@
+Avoid :exc:`NameError` for the :mod:`warnings` module when accessing the
+depracated atributes of the :mod:`importlib.abc` module.