]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-136047: Allow typing._allow_reckless_class_checks to check `_py_abc` (#136115)
authorJeong, YunWon <69878+youknowone@users.noreply.github.com>
Sat, 5 Jul 2025 14:24:33 +0000 (23:24 +0900)
committerGitHub <noreply@github.com>
Sat, 5 Jul 2025 14:24:33 +0000 (14:24 +0000)
Lib/typing.py
Misc/NEWS.d/next/Library/2025-07-05-06-59-46.gh-issue-136047.qWvycf.rst [new file with mode: 0644]

index 4ebf0eb92f589f962107f33c4e5a03d4c7d2cbf8..27105838a0a06498d7b603f59429310123c7cca1 100644 (file)
@@ -1866,7 +1866,9 @@ def _allow_reckless_class_checks(depth=2):
     The abc and functools modules indiscriminately call isinstance() and
     issubclass() on the whole MRO of a user class, which may contain protocols.
     """
-    return _caller(depth) in {'abc', 'functools', None}
+    # gh-136047: When `_abc` module is not available, `_py_abc` is required to
+    # allow `_py_abc.ABCMeta` fallback.
+    return _caller(depth) in {'abc', '_py_abc', 'functools', None}
 
 
 _PROTO_ALLOWLIST = {
diff --git a/Misc/NEWS.d/next/Library/2025-07-05-06-59-46.gh-issue-136047.qWvycf.rst b/Misc/NEWS.d/next/Library/2025-07-05-06-59-46.gh-issue-136047.qWvycf.rst
new file mode 100644 (file)
index 0000000..1a38186
--- /dev/null
@@ -0,0 +1,2 @@
+Fix issues with :mod:`typing` when the C implementation of :mod:`abc` is not
+available.