-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when there a "._xxx.pth" on macOS #113356
Comments
On macOS the system can create a "._" file next to a regular file when the system needs to store metadata that is not supported by the filesystem (such as storing extended attributes on an exFAT filesystem). Those files are binary data and cause startup failures when the base file is a ".pth" file.
Thank you for your attention! I am the one who report this. Python version: Python 3.11.6 (main, Nov 2 2023, 04:39:43) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin Reproduce steps:
The
Sorry for anything bad since I'm not so good at English. :( |
[...]
Thanks for the update. And don't worry about your English, it is perfectly clear. |
@quul, What's the output of the following commands (before removing the "._" files):
Not really important, but I'm curious what metadata is added on your system. I don't have an external disk lying around that I can format exFAT, otherwise I'd test myself. |
@ronaldoussoren, you perhaps can create a file system in a file and them mount it. At least it is easy to do on Linux:
We can ignore UnicodeDecodeError as well as OSError when open a pth file (although the code will be more complex to avoid leaks), but I think that it is reasonable to skip dot-files when list pth files at first place. |
I can reproduce the issue using a disk image, but only by manually settings some extended attributes. Users on the d.p.o thread I link to run into this without doing anything special. The only difference is that they use an external disk. |
I’m glad to do the test. However I just started my vocation and not carrying the mac with me. |
This has been fixed by #113659, which will ignore all hidden PTH files, including those with a filename starting with a dot like the |
Bug report
Bug description:
See https://discuss.python.org/t/venv-not-function-properly-in-macos-within-an-exfat-disk/26145 for the original report.
MacOS creates "._" files with additional metadata when there is metadata (such as extended attributes) that the filesystem doesn't support natively.
To reproduce (I did this on macOS 13 to match the forum message, likely also happens on 14):
Create a disk image with the exFAT format and mount this
Create a virtual environment on this volume and active this
Install setup tools (which ships with a PTH file name
distutils-precedence.pth
)Use the "Get Info" context menu in the finder for the PTH file and add a note to the metadata
There should now be a
._distutils-precedence.pth
fileAlternatively: use
xattr -w name value distutils-precedence.pth
to write an extended attribute.Start "python"
This should fail with a UnicodeDecodeError in site.py
CPython versions tested on:
3.12
Operating systems tested on:
macOS
Linked PRs
The text was updated successfully, but these errors were encountered: