From 887e5c8646dfc6dd3d64b482c5310a414ac9162b Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" <69878+youknowone@users.noreply.github.com> Date: Sat, 5 Jul 2025 23:24:33 +0900 Subject: [PATCH] gh-136047: Allow typing._allow_reckless_class_checks to check `_py_abc` (#136115) --- Lib/typing.py | 4 +++- .../Library/2025-07-05-06-59-46.gh-issue-136047.qWvycf.rst | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2025-07-05-06-59-46.gh-issue-136047.qWvycf.rst diff --git a/Lib/typing.py b/Lib/typing.py index 4ebf0eb92f58..27105838a0a0 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -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 index 000000000000..1a381860914b --- /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. -- 2.47.3