https://github.com/python/cpython/commit/74c91a6fbfa3625cdc850acc99b509cc3d8c6ed0
commit: 74c91a6fbfa3625cdc850acc99b509cc3d8c6ed0
branch: main
author: Zanie Blue <[email protected]>
committer: itamaro <[email protected]>
date: 2026-10-23T17:14:45Z
summary:

gh-160359: Accept older musl `getdents64` buffer declarations (#160365)

Older musl headers expose `getdents64` as an alias for `getdents`, whose buffer 
parameter is `struct dirent *`. Passing the raw character buffer triggers an 
incompatible-pointer diagnostic. Pass it through `void *` to support both that 
interface and the glibc declaration.

Ports PBS's 
[`patch-posixsubprocess-musl-getdents64.patch`](https://github.com/astral-sh/python-build-standalone/blob/0c5e581b54a4736cdbbe68bdd6d7e571a1dca11e/cpython-unix/patch-posixsubprocess-musl-getdents64.patch).

files:
M Modules/_posixsubprocess.c

diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index 2291280ec117f2..415e0afbe88125 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -436,7 +436,11 @@ _close_open_fds_safe(int start_fd, int *fds_to_keep, 
Py_ssize_t fds_to_keep_len)
         Py_ssize_t bytes;
         while (1) {
 #ifdef HAVE_GETDENTS64
-            bytes = getdents64(fd_dir_fd, buffer, sizeof(buffer));
+            /* musl <1.2.4 headers expose `getdents64` as an alias for 
`getdents`, whose buffer parameter
+             * is `struct dirent *`. We use `void *` to support both that 
interface and the glibc declaration
+             * without an incompatible-pointer diagnostic.
+             */
+            bytes = getdents64(fd_dir_fd, (void *)buffer, sizeof(buffer));
 #else
             bytes = syscall(SYS_getdents64, fd_dir_fd,
                             (struct py_dirent64 *)buffer, sizeof(buffer));

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to