Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-113356: Ignore errors in "._ABC.pth"#113357

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ronaldoussoren wants to merge5 commits intopython:mainfromronaldoussoren:gh-113356
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletionsLib/site.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -176,6 +176,18 @@ def addpackage(sitedir, name, known_paths):
except OSError:
return
with f:
if name.startswith("._"):
# MacOS will create "._" files next to a regular file
# when a filesystem driver needs to store metadata that
# cannot be stored natively. Such files are encoded
# in AppleDouble format.
# The test looks for the magic marker at the start of such
# files.
if f.buffer.read(4) == b"\x00\x05\x16\x07" \
and os.path.exists(os.path.join(sitedir, name[2:])):
return
f.seek(0)

for n, line in enumerate(f):
if line.startswith("#"):
continue
Expand Down
21 changes: 21 additions & 0 deletionsLib/test/test_site.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -181,6 +181,27 @@ def test_addpackage_import_bad_pth_file(self):
if isinstance(path, str):
self.assertNotIn("abc\x00def", path)

def test_addpackage_macOS_resources(self):
# GH-113356
pth_dir, pth_fn = self.make_pth("dummy\n")
resource_fork = os.path.join(pth_dir, "._" + pth_fn)
with open(resource_fork, "wb") as fp:
self.addCleanup(lambda: os.remove(resource_fork))

# The bytes below were generated on macOS 14 using an
# exFAT filesystem. Command to write an xattr:
# `xattr -w key value test.txt`. These bytes are not
# the complete AppleDouble file, but just a significant
# prefix.
fp.write(b'\x00\x05\x16\x07\x00\x02\x00\x00Mac OS X ')
fp.write(b'\x00\x02\x00\x00\x00\t\x00\x00\x002\x00\x00\x0e')
fp.write(b'\xb0\x00\x00\x00\x02\x00\x00\x0e\xe2\x00\x00')
fp.write(b'\x01\x1e')

with captured_stderr() as err_out:
self.assertFalse(site.addpackage(pth_dir, "._" + pth_fn, set()))
self.assertEqual(err_out.getvalue(), "")

def test_addsitedir(self):
# Same tests for test_addpackage since addsitedir() essentially just
# calls addpackage() for every .pth file in the directory
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
Ignore "._" prefixed pth files when those cannot be parsed. These files are
created on macOS when the system tries store metadata that is not supported
by the filesystem (such as extended attributes on exFAT)

[8]ページ先頭

©2009-2025 Movatter.jp