diff --git a/Lib/typing.py b/Lib/typing.py index ed1dd4fc6413a5..e8a61e64833602 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1860,7 +1860,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 index 00000000000000..1a381860914bc3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-07-05-06-59-46.gh-issue-136047.qWvycf.rst @@ -0,0 +1,2 @@ +Fix issues with :mod:`typing` when the C implementation of :mod:`abc` is not +available.