From 862fd890361005598a6f4614ea0608c8447831c2 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 22 Apr 2025 22:22:57 -0500 Subject: [PATCH] gh-109981: Resolve situation on iOS regarding fd_count. (#132823) Modifies the test helper that counts the list of open file descriptors to use the optimised ``/dev/fd`` approach on all Apple platforms, not just macOS. This avoids crashes caused by guarded file descriptors. --- Lib/test/support/os_helper.py | 2 +- .../next/Tests/2025-04-23-02-23-37.gh-issue-109981.IX3k8p.rst | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Tests/2025-04-23-02-23-37.gh-issue-109981.IX3k8p.rst diff --git a/Lib/test/support/os_helper.py b/Lib/test/support/os_helper.py index d82093e375c8..2c45fe2369ec 100644 --- a/Lib/test/support/os_helper.py +++ b/Lib/test/support/os_helper.py @@ -657,7 +657,7 @@ def fd_count(): """ if sys.platform.startswith(('linux', 'android', 'freebsd', 'emscripten')): fd_path = "/proc/self/fd" - elif sys.platform == "darwin": + elif support.is_apple: fd_path = "/dev/fd" else: fd_path = None diff --git a/Misc/NEWS.d/next/Tests/2025-04-23-02-23-37.gh-issue-109981.IX3k8p.rst b/Misc/NEWS.d/next/Tests/2025-04-23-02-23-37.gh-issue-109981.IX3k8p.rst new file mode 100644 index 000000000000..175615258303 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2025-04-23-02-23-37.gh-issue-109981.IX3k8p.rst @@ -0,0 +1,3 @@ +The test helper that counts the list of open file descriptors now uses the +optimised ``/dev/fd`` approach on all Apple platforms, not just macOS. +This avoids crashes caused by guarded file descriptors. -- 2.47.3