Skip to content

Commit

Permalink
[3.13] pythongh-121279: Re-add prematurely removed import warnings to…
Browse files Browse the repository at this point in the history
… importlib.abc

Fixup for 5172462

Fixes python#121279
  • Loading branch information
hroncok committed Jul 2, 2024
1 parent 78e96bd commit 4f3e53f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lib/importlib/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
_frozen_importlib_external = _bootstrap_external
from ._abc import Loader
import abc
import warnings

from .resources import abc as _resources_abc

Expand Down
22 changes: 22 additions & 0 deletions Lib/test/test_importlib/test_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,5 +913,27 @@ def test_universal_newlines(self):
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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Avoid :exc:`NameError` for the :mod:`warnings` module when accessing the
depracated atributes of the :mod:`importlib.abc` module.

0 comments on commit 4f3e53f

Please sign in to comment.