summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/metadata
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2023-04-22 17:52:51 (GMT)
committerGitHub <noreply@github.com>2023-04-22 17:52:51 (GMT)
commit916de04fd1838530096336aadb3b94b774ed6c90 (patch)
tree99006797b2ef7b0c8a55a7e935c122ca8b505140 /Lib/importlib/metadata
parent3d2a46845b67407e2436d910b2e1740c34f4f10d (diff)
downloadcpython-916de04fd1838530096336aadb3b94b774ed6c90.zip
cpython-916de04fd1838530096336aadb3b94b774ed6c90.tar.gz
cpython-916de04fd1838530096336aadb3b94b774ed6c90.tar.bz2
gh-103661: Apply bugfix from importlib_metadata 6.5.1 and restore test. (#103681)
Diffstat (limited to 'Lib/importlib/metadata')
-rw-r--r--Lib/importlib/metadata/__init__.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/Lib/importlib/metadata/__init__.py b/Lib/importlib/metadata/__init__.py
index b8eb19d..82e0ce1 100644
--- a/Lib/importlib/metadata/__init__.py
+++ b/Lib/importlib/metadata/__init__.py
@@ -516,27 +516,29 @@ class Distribution(DeprecatedNonAbstract):
"""
Read installed-files.txt and return lines in a similar
CSV-parsable format as RECORD: each file must be placed
- relative to the site-packages directory, and must also be
+ relative to the site-packages directory and must also be
quoted (since file names can contain literal commas).
This file is written when the package is installed by pip,
but it might not be written for other installation methods.
- Hence, even if we can assume that this file is accurate
- when it exists, we cannot assume that it always exists.
+ Assume the file is accurate if it exists.
"""
text = self.read_text('installed-files.txt')
- # We need to prepend the .egg-info/ subdir to the lines in this file.
- # But this subdir is only available in the PathDistribution's self._path
- # which is not easily accessible from this base class...
+ # Prepend the .egg-info/ subdir to the lines in this file.
+ # But this subdir is only available from PathDistribution's
+ # self._path.
subdir = getattr(self, '_path', None)
if not text or not subdir:
return
- with contextlib.suppress(Exception):
- ret = [
- str((subdir / line).resolve().relative_to(self.locate_file('')))
- for line in text.splitlines()
- ]
- return map('"{}"'.format, ret)
+
+ paths = (
+ (subdir / name)
+ .resolve()
+ .relative_to(self.locate_file('').resolve())
+ .as_posix()
+ for name in text.splitlines()
+ )
+ return map('"{}"'.format, paths)
def _read_files_egginfo_sources(self):
"""