[Python-checkins] [3.11] gh-101857: Allow xattr detection on musl libc (GH-101858) (#101894)

gpshead webhook-mailer at python.org
Sat May 20 20:17:34 EDT 2023


https://github.com/python/cpython/commit/2e457bc202179445cbf7b3a2a96c8450f1cda72f
commit: 2e457bc202179445cbf7b3a2a96c8450f1cda72f
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: gpshead <greg at krypto.org>
date: 2023-05-21T00:17:27Z
summary:

[3.11] gh-101857: Allow xattr detection on musl libc (GH-101858) (#101894)

gh-101857: Allow xattr detection on musl libc (GH-101858)

Previously, we checked exclusively for `__GLIBC__` (AND'd with some other
conditions). Checking for `__linux__` instead should be fine.

This fixes using e.g. `os.listxattr()` on systems using musl libc.

Bug: https://bugs.gentoo.org/894130

(cherry picked from commit 8be8101bca34b60481ec3d7ecaea4a3379fb7dbb)

Co-authored-by: Sam James <sam at gentoo.org>
Co-authored-by: Gregory P. Smith <greg at krypto.org>

files:
A Misc/NEWS.d/next/Core and Builtins/2023-02-12-22-40-22.gh-issue-101857._bribG.rst
M Modules/posixmodule.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-02-12-22-40-22.gh-issue-101857._bribG.rst b/Misc/NEWS.d/next/Core and Builtins/2023-02-12-22-40-22.gh-issue-101857._bribG.rst
new file mode 100644
index 000000000000..832cc300fa94
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2023-02-12-22-40-22.gh-issue-101857._bribG.rst	
@@ -0,0 +1 @@
+Fix xattr support detection on Linux systems by widening the check to linux, not just glibc. This fixes support for musl.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index c825aeedcf08..a01662d868e5 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -280,8 +280,9 @@ corresponding Unix manual entries for more information on calls.");
 #  undef HAVE_SCHED_SETAFFINITY
 #endif
 
-#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
+#if defined(HAVE_SYS_XATTR_H) && defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__)
 #  define USE_XATTRS
+#  include <linux/limits.h>  // Needed for XATTR_SIZE_MAX on musl libc.
 #endif
 
 #ifdef USE_XATTRS



More information about the Python-checkins mailing list