diff options
| author | Miro HronĨok <miro@hroncok.cz> | 2024-07-03 09:06:20 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-03 09:06:20 (GMT) |
| commit | dacf4ffa7982e13dce87ecb61b3b21e99375298a (patch) | |
| tree | 56d95701a1f09f2c0c792e4fe8d9280144701193 | |
| parent | ee1db25bc0ea9309f834b154bdf5bdd81830a8f3 (diff) | |
| download | cpython-dacf4ffa7982e13dce87ecb61b3b21e99375298a.zip cpython-dacf4ffa7982e13dce87ecb61b3b21e99375298a.tar.gz cpython-dacf4ffa7982e13dce87ecb61b3b21e99375298a.tar.bz2 | |
[3.13] gh-121279: Re-add prematurely removed import warnings to importlib.abc (#121281)
Fixup for 51724620e868512bbedb1547aca441bcd27bbe0c
Fixes https://github.com/python/cpython/issues/121279
| -rw-r--r-- | Lib/importlib/abc.py | 1 | ||||
| -rw-r--r-- | Lib/test/test_importlib/test_abc.py | 22 | ||||
| -rw-r--r-- | Misc/NEWS.d/next/Library/2024-07-02-19-36-54.gh-issue-121279.BltDo9.rst | 2 |
3 files changed, 25 insertions, 0 deletions
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py index 16b9626..37fef35 100644 --- a/Lib/importlib/abc.py +++ b/Lib/importlib/abc.py @@ -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 diff --git a/Lib/test/test_importlib/test_abc.py b/Lib/test/test_importlib/test_abc.py index 603125f..4790390 100644 --- a/Lib/test/test_importlib/test_abc.py +++ b/Lib/test/test_importlib/test_abc.py @@ -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 index 0000000..709a378 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-07-02-19-36-54.gh-issue-121279.BltDo9.rst @@ -0,0 +1,2 @@ +Avoid :exc:`NameError` for the :mod:`warnings` module when accessing the +depracated atributes of the :mod:`importlib.abc` module. |
