]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109981: Resolve situation on iOS regarding fd_count. (#132823)
authorJohn <johnzhou721@gmail.com>
Wed, 23 Apr 2025 03:22:57 +0000 (22:22 -0500)
committerGitHub <noreply@github.com>
Wed, 23 Apr 2025 03:22:57 +0000 (03:22 +0000)
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
Misc/NEWS.d/next/Tests/2025-04-23-02-23-37.gh-issue-109981.IX3k8p.rst [new file with mode: 0644]

index d82093e375c8b164db76ea5c782fab1dc93afa44..2c45fe2369ec36b574258e701bfc078114c5499d 100644 (file)
@@ -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 (file)
index 0000000..1756152
--- /dev/null
@@ -0,0 +1,3 @@
+The test helper that counts the list of open file descriptors now uses the\r
+optimised ``/dev/fd`` approach on all Apple platforms, not just macOS.\r
+This avoids crashes caused by guarded file descriptors.\r