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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trailing slash handling in pkg_resources.ZipProvider #1232

Merged
merged 5 commits into from Dec 25, 2017

Conversation

Projects
None yet
2 participants
@duggelz
Contributor

duggelz commented Dec 12, 2017

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.

Fixes #1188

Doug Greiman added some commits Nov 5, 2017

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.
@jaraco

Looks good to me. No objections to include. Could you add a changelog entry to CHANGES.txt for a new release with an 0.0.1 bump?

@@ -1693,6 +1693,10 @@ def __init__(self, module):
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]

This comment has been minimized.

@jaraco

jaraco Dec 22, 2017

Member

Could these two lines be fspath = fspath.rstrip(os.sep)?

This comment has been minimized.

@duggelz

duggelz Dec 22, 2017

Contributor

Done

Doug Greiman added some commits Dec 22, 2017

@duggelz

This comment has been minimized.

Contributor

duggelz commented Dec 22, 2017

Added changelog entry, bumped version number, and rebased to head. Thanks.

@jaraco jaraco merged commit 1ad2c11 into pypa:master Dec 25, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jaraco

This comment has been minimized.

Member

jaraco commented Dec 25, 2017

Excellent. With those changes, I can cut the release from my comm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment