Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 894130 - dev-lang/python - os module is missing xattr functions on musl based systems
Summary: dev-lang/python - os module is missing xattr functions on musl based systems
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2023-02-12 20:54 UTC by immolo
Modified: 2023-02-14 15:05 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch (python-3.10.9-xattr-muslfix.patch,463 bytes, patch)
2023-02-12 20:56 UTC, immolo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description immolo 2023-02-12 20:54:50 UTC
While testing 23.0 profiles for running on MIPS I found sys-app/merge-usr was failing to run with "AttributeError: module 'os' has no attribute 'listxattr'" so based on this it looks like all Musl systems will have the same issue.

Reproducible: Always

Steps to Reproduce:
1. Setup musl stage3
2. add "sys-apps/merge-usr **" if your arch requires it to /etc/portage/package.accept_keywords/merge-usr
3. emerge -va1 sys-apps/merge-usr
4. run `merge-usr --dryrun`
5. If successful then run `merge-usr`
Actual Results:  
# merge-usr
INFO: Migrating files from '/bin' to '/usr/bin'
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.10/merge-usr", line 308, in <module>
    sys.exit(main())
  File "/usr/lib/python-exec/python3.10/merge-usr", line 303, in main
    if not mu.run():
  File "/usr/lib/python-exec/python3.10/merge-usr", line 257, in run
    self.copy_tree(src, dst)
  File "/usr/lib/python-exec/python3.10/merge-usr", line 225, in copy_tree
    self.link_or_copy_file(src, dst)
  File "/usr/lib/python-exec/python3.10/merge-usr", line 189, in link_or_copy_file
    replace_file_with_symlink(src, dst)
  File "/usr/lib/python-exec/python3.10/merge-usr", line 65, in replace_file_with_symlink
    copy_xattrs(src, tmp)
  File "/usr/lib/python-exec/python3.10/merge-usr", line 58, in copy_xattrs
    set_xattrs(dst, attrs)
  File "/usr/lib/python-exec/python3.10/merge-usr", line 49, in set_xattrs
    for (name, value) in attrs:
  File "/usr/lib/python-exec/python3.10/merge-usr", line 37, in get_xattrs
    attrs = os.listxattr(path, follow_symlinks=False)
AttributeError: module 'os' has no attribute 'listxattr'


After looking around for a solution I have found Alpine has a patch for this which I have rebased for python-3.10.9 and have confirmed it as a working solution. This needs further testing to see if it will cause any issue to GLIBC users or if it needs to be applied to the Musl repo before the 23.0 rollout happens.
Comment 1 immolo 2023-02-12 20:56:57 UTC
Created attachment 850594 [details, diff]
patch

This is the tested patched I have used and confirmed working on Musl systems.
Comment 2 Violet Purcell 2023-02-12 22:20:18 UTC
I have had the same issue on musl. Can confirm the patch works, albeit I modified it for 3.11.2 by changing
--- a/posixmodule.c	2022-12-06 18:31:21.000000000 +0000
+++ b/posixmodule.c	2023-02-12 13:48:56.645137457 +0000
to
--- a/Modules/posixmodule.c	2022-12-06 18:31:21.000000000 +0000
+++ b/Modules/posixmodule.c	2023-02-12 13:48:56.645137457 +0000
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-12 22:22:16 UTC Comment hidden (obsolete)
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-14 04:36:47 UTC
https://github.com/python/cpython/pull/101858 is approved upstream. We'll backport it later today.
Comment 5 Larry the Git Cow gentoo-dev 2023-02-14 15:05:03 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7e4bc93cfd8c98df45018b72f6ac4bfc5c698bcf

commit 7e4bc93cfd8c98df45018b72f6ac4bfc5c698bcf
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2023-02-14 14:48:15 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2023-02-14 15:00:41 +0000

    dev-lang/python: Backport fixes to 3.8.16_p2
    
    Closes: https://bugs.gentoo.org/894130
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 dev-lang/python/Manifest                                             | 2 +-
 dev-lang/python/{python-3.8.16-r3.ebuild => python-3.8.16_p2.ebuild} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d73f7567fff43888dd3406de67ef6e65d821916e

commit d73f7567fff43888dd3406de67ef6e65d821916e
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2023-02-14 14:46:40 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2023-02-14 14:49:23 +0000

    dev-lang/python: Backport fixes to 3.9.16_p1
    
    Closes: https://bugs.gentoo.org/894130
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 dev-lang/python/Manifest                                             | 2 +-
 dev-lang/python/{python-3.9.16-r1.ebuild => python-3.9.16_p1.ebuild} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ad9c6f81a97735aaa958dd55c2823465593e8a76

commit ad9c6f81a97735aaa958dd55c2823465593e8a76
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2023-02-14 14:45:18 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2023-02-14 14:49:19 +0000

    dev-lang/python: Backport musl xattr fix to 3.10.10_p1
    
    Closes: https://bugs.gentoo.org/894130
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 dev-lang/python/Manifest                                            | 2 +-
 dev-lang/python/{python-3.10.10.ebuild => python-3.10.10_p1.ebuild} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=33a1368227f4299a3dd2a17d4f4509dfdd36fcd7

commit 33a1368227f4299a3dd2a17d4f4509dfdd36fcd7
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2023-02-14 14:44:07 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2023-02-14 14:49:07 +0000

    dev-lang/python: Backport musl xattr fix to 3.11.2_p1
    
    Closes: https://bugs.gentoo.org/894130
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 dev-lang/python/Manifest                                          | 2 +-
 dev-lang/python/{python-3.11.2.ebuild => python-3.11.2_p1.ebuild} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)