Fix packaging.database.Distribution.list_distinfo_files (#12785).
This method was supposed to return only the file under the dist-info
directory, but it actually returned all installed files.
The tests didn’t catch this because they were flawed; I updated them.
Thanks to Nadeem Vawda and Jeremy Kloth for testing.
As a bonus, the removal of os.path.relpath use should also fix the
Windows buildbots.
diff --git a/Lib/packaging/database.py b/Lib/packaging/database.py
index c733b7a..b606db6 100644
--- a/Lib/packaging/database.py
+++ b/Lib/packaging/database.py
@@ -263,7 +263,9 @@
:returns: iterator of paths
"""
for path, checksum, size in self._get_records(local):
- yield path
+ # XXX add separator or use real relpath algo
+ if path.startswith(self.path):
+ yield path
def __eq__(self, other):
return isinstance(other, Distribution) and self.path == other.path