Skip to content

Commit 0cee228

Browse files
committed
pythongh-103661: Apply bugfix from importlib_metadata 6.5.1 and restore test.
1 parent 7b134d3 commit 0cee228

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

Lib/importlib/metadata/__init__.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -516,27 +516,29 @@ def _read_files_egginfo_installed(self):
516516
"""
517517
Read installed-files.txt and return lines in a similar
518518
CSV-parsable format as RECORD: each file must be placed
519-
relative to the site-packages directory, and must also be
519+
relative to the site-packages directory and must also be
520520
quoted (since file names can contain literal commas).
521521
522522
This file is written when the package is installed by pip,
523523
but it might not be written for other installation methods.
524-
Hence, even if we can assume that this file is accurate
525-
when it exists, we cannot assume that it always exists.
524+
Assume the file is accurate if it exists.
526525
"""
527526
text = self.read_text('installed-files.txt')
528-
# We need to prepend the .egg-info/ subdir to the lines in this file.
529-
# But this subdir is only available in the PathDistribution's self._path
530-
# which is not easily accessible from this base class...
527+
# Prepend the .egg-info/ subdir to the lines in this file.
528+
# But this subdir is only available from PathDistribution's
529+
# self._path.
531530
subdir = getattr(self, '_path', None)
532531
if not text or not subdir:
533532
return
534-
with contextlib.suppress(Exception):
535-
ret = [
536-
str((subdir / line).resolve().relative_to(self.locate_file('')))
537-
for line in text.splitlines()
538-
]
539-
return map('"{}"'.format, ret)
533+
534+
paths = (
535+
(subdir / name)
536+
.resolve()
537+
.relative_to(self.locate_file('').resolve())
538+
.as_posix()
539+
for name in text.splitlines()
540+
)
541+
return map('"{}"'.format, paths)
540542

541543
def _read_files_egginfo_sources(self):
542544
"""

Lib/test/test_importlib/test_metadata_api.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,12 @@ def test_for_top_level(self):
7676
expect_content,
7777
)
7878

79-
@staticmethod
80-
def _workaround_103661(tests):
81-
"""
82-
Skip failing test for now is it's failing on buildbot workers.
83-
See https://github.com/python/cpython/issues/103661.
84-
"""
85-
import platform
86-
if platform.system() == 'Windows':
87-
tests.remove(('egg_with_no_modules-pkg', '\n'))
88-
return tests
89-
9079
def test_read_text(self):
9180
tests = [
9281
('egginfo-pkg', 'mod\n'),
9382
('egg_with_no_modules-pkg', '\n'),
9483
]
95-
for pkg_name, expect_content in self._workaround_103661(tests):
84+
for pkg_name, expect_content in tests:
9685
with self.subTest(pkg_name):
9786
top_level = [
9887
path for path in files(pkg_name) if path.name == 'top_level.txt'

0 commit comments

Comments
 (0)