[3.13] gh-121279: Re-add prematurely removed import warnings to importlib.abc (#121281)

Fixup for 51724620e8

Fixes https://github.com/python/cpython/issues/121279
This commit is contained in:
Miro Hrončok 2024-07-03 11:06:20 +02:00 committed by GitHub
parent ee1db25bc0
commit dacf4ffa79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 0 deletions

View 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

View 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()

View file

@ -0,0 +1,2 @@
Avoid :exc:`NameError` for the :mod:`warnings` module when accessing the
depracated atributes of the :mod:`importlib.abc` module.