https://github.com/python/cpython/commit/83c7dd5200bae16d2f2f942fb0a826723d3023cc
commit: 83c7dd5200bae16d2f2f942fb0a826723d3023cc
branch: 3.12
author: Jelle Zijlstra <[email protected]>
committer: JelleZijlstra <[email protected]>
date: 2024-02-16T13:46:48-08:00
summary:

[3.12] gh-115570: Fix DeprecationWarnings in test_typing (#115571) (#115574)

Co-authored-by: Alex Waygood <[email protected]>

files:
A Misc/NEWS.d/next/Library/2024-02-16-10-18-25.gh-issue-115570.bI6uu3.rst
M Lib/test/test_typing.py
M Lib/typing.py

diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index ab9d8a0a20ce7d..7f9c10dd2a54e6 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -8123,6 +8123,17 @@ def test_re_submodule(self):
             self.assertEqual(__name__, 'typing.re')
             self.assertEqual(len(w), 1)
 
+    def test_re_submodule_access_basics(self):
+        with warnings.catch_warnings():
+            warnings.filterwarnings("error", category=DeprecationWarning)
+            from typing import re
+            self.assertIsInstance(re.__doc__, str)
+            self.assertEqual(re.__name__, "typing.re")
+            self.assertIsInstance(re.__dict__, types.MappingProxyType)
+
+        with self.assertWarns(DeprecationWarning):
+            re.Match
+
     def test_cannot_subclass(self):
         with self.assertRaisesRegex(
             TypeError,
diff --git a/Lib/typing.py b/Lib/typing.py
index cbd4ce8bfaa6bb..1e4c725be473b7 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -3256,11 +3256,11 @@ def __enter__(self) -> 'TextIO':
 
 class _DeprecatedType(type):
     def __getattribute__(cls, name):
-        if name not in ("__dict__", "__module__") and name in cls.__dict__:
+        if name not in {"__dict__", "__module__", "__doc__"} and name in 
cls.__dict__:
             warnings.warn(
                 f"{cls.__name__} is deprecated, import directly "
                 f"from typing instead. {cls.__name__} will be removed "
-                "in Python 3.12.",
+                "in Python 3.13.",
                 DeprecationWarning,
                 stacklevel=2,
             )
diff --git 
a/Misc/NEWS.d/next/Library/2024-02-16-10-18-25.gh-issue-115570.bI6uu3.rst 
b/Misc/NEWS.d/next/Library/2024-02-16-10-18-25.gh-issue-115570.bI6uu3.rst
new file mode 100644
index 00000000000000..f3c8a11380a283
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-02-16-10-18-25.gh-issue-115570.bI6uu3.rst
@@ -0,0 +1,3 @@
+A :exc:`DeprecationWarning` is no longer omitted on access to the
+``__doc__`` attributes of the deprecated ``typing.io`` and ``typing.re``
+pseudo-modules.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to