Skip to content

bpo-5950: Support reading zips with comments in zipimport#9548

Merged
warsaw merged 2 commits into
python:masterfrom
ZackerySpytz:bpo-5950-zipimport-zip-comments
Sep 25, 2018
Merged

bpo-5950: Support reading zips with comments in zipimport#9548
warsaw merged 2 commits into
python:masterfrom
ZackerySpytz:bpo-5950-zipimport-zip-comments

Conversation

@ZackerySpytz

@ZackerySpytz ZackerySpytz commented Sep 24, 2018

Copy link
Copy Markdown
Contributor

Some of the code is based on _EndRecData() in Lib/zipfile.py.

https://bugs.python.org/issue5950

@dsamersoff

Copy link
Copy Markdown

Looks good to me.
Glad to see it fixed after nine years ;)

@warsaw warsaw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding support for a long standing request! I have a few questions about code details, but in general it LGTM.

Comment thread Lib/test/test_zipimport.py
Comment thread Lib/zipimport.py Outdated
raise ZipImportError(f"can't open Zip file: {archive!r}", path=archive)

with fp:
end_cent_dir_size = 22

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps make this a module constant, all upper cased? Also, what does the abbreviation "cent" mean?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. "cent" means "central".

Comment thread Lib/zipimport.py Outdated
if len(buffer) != end_cent_dir_size:
raise ZipImportError(f"can't read Zip file: {archive!r}", path=archive)
if buffer[:4] != b'PK\x05\x06':
string_end_archive = b'PK\x05\x06'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another candidate for a module constant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread Lib/zipimport.py Outdated
except OSError:
raise ZipImportError(f"can't read Zip file: {archive!r}",
path=archive)
max_comment_len = (1 << 16) - 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another candidate for a module constant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ZackerySpytz

Copy link
Copy Markdown
Contributor Author

Thank you, @warsaw, for the comments.

I have made the requested changes; please review again.

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@warsaw: please review the changes made to this pull request.

@warsaw warsaw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. LGTM!

@warsaw
warsaw merged commit 5a5ce06 into python:master Sep 25, 2018
@bedevere-bot

Copy link
Copy Markdown

@warsaw: Please replace # with GH- in the commit message next time. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants