Commit 7b8b56fa authored by Doug Greiman's avatar Doug Greiman

Fix trailing slash handling in pkg_resources.ZipProvider

Given a ZipProvider, if the underlying ZipImporter prefix is empty,
then resource_listdir('') and resource_listdir('subdir/') fail, while
resource_listdir('/') and resource_listdir('subdir') succeed.

On the other hand, if the underlying ZipImport prefix is not empty,
then resource_listdir('/') fails but resource_listdir('') succeeds.

With this change, the cases listed succeed with or without trailing
slashes.
parent 66729ab5
......@@ -1693,6 +1693,10 @@ class ZipProvider(EggProvider):
def _zipinfo_name(self, fspath):
# Convert a virtual filename (full path to file) into a zipfile subpath
# usable with the zipimport directory cache for our target archive
while fspath.endswith(os.sep):
fspath = fspath[:-1]
if fspath == self.loader.archive:
return ''
if fspath.startswith(self.zip_pre):
return fspath[len(self.zip_pre):]
raise AssertionError(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment