-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-5950: Support reading zips with comments in zipimport #9548
bpo-5950: Support reading zips with comments in zipimport #9548
Conversation
Looks good to me. |
There was a problem hiding this comment.
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.
Lib/zipimport.py
Outdated
@@ -353,17 +353,43 @@ def _read_directory(archive): | |||
raise ZipImportError(f"can't open Zip file: {archive!r}", path=archive) | |||
|
|||
with fp: | |||
end_cent_dir_size = 22 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. "cent" means "central".
Lib/zipimport.py
Outdated
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' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Lib/zipimport.py
Outdated
except OSError: | ||
raise ZipImportError(f"can't read Zip file: {archive!r}", | ||
path=archive) | ||
max_comment_len = (1 << 16) - 1 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
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 |
Thank you, @warsaw, for the comments. I have made the requested changes; please review again. |
Thanks for making the requested changes! @warsaw: please review the changes made to this pull request. |
There was a problem hiding this comment.
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: Please replace |
Some of the code is based on
_EndRecData()
in Lib/zipfile.py.https://bugs.python.org/issue5950