-
-
Notifications
You must be signed in to change notification settings - Fork 35k
bpo-39667: Sync zipp 3.0 #18540
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
Merged
Merged
bpo-39667: Sync zipp 3.0 #18540
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b178695
bpo-39667: Improve pathlib.Path compatibility on zipfile.Path and cor…
jaraco 7a827ff
📜🤖 Added by blurb_it.
blurb-it[bot] 671ab3e
Update docs for new zipfile.Path.open
jaraco 3d9272a
Rely on dict, faster than OrderedDict.
jaraco 34d7114
Syntax edits on docs
jaraco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Library/2020-02-17-22-38-15.bpo-39667.QuzEHH.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Improve pathlib.Path compatibility on zipfile.Path and correct performance degradation as found in zipp 3.0. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 changes the return type of
Zipfile.Path.openfrom bytes to string and could be backwards incompatible on backporting to 3.8Uh oh!
There was an error while loading. Please reload this page.
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 highlighting this concern. It's this concern that's kept me from fast-tracking this change. I'll try to enumerate the rationale and concerns and alternatives (to simply breaking it).
Rationale
zipfile.Pathwas intended to be compatible with a subset ofpathlib.Path.pathlib.Pathcompatible implementation of.open()would be useful if not necessary.Pathobjects to have a consistent and compatible interface..open()probably should have been kept as a private (._open()) interface until it was needed..open()today can readily callPath.root.open()to get the current behavior.zipp) would have already been exposed to this change (via zipp 3.0) and likely have adapted. No concerns were raised.Concerns
.open()implementation..open(). If not for this concern, one might have been able to make the argument that.open()was an internal implementation detail..open()methods as currently implemented.pathlib.Pathrequiresmode='rb'to return bytes andzipfile.Pathfails if 'b' is passed.zipfile, but also by consumers of APIs that returnzipfile.Path(i.e.importlib.metadata).Alternatives
I'm considering several possible approaches.
zipfile.Path._future_openonly on Python 3.8 that users could call to get the future behavior.FuturePathonly on Python 3.8 that would implement the alternate interface and would be supplied byimportlib.metadataand others._legacy_openthat provides the legacy behavior. That seems unnecessary given thatzipfile.Path.root.openexists.Regardless of how we proceed, there are some actions.
Uh oh!
There was an error while loading. Please reload this page.
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.
After mulling this over throughout the week and capturing the rationale and concerns above, I'm leaning toward making this backward-incompatible change in Python 3.8.x, assuming you agree and think the concern is manageable. Here's how that would work:
zipfile.Path.openin Python 3.8.(next-1) to usezipfile.Path.root.openinstead for easy, straightforward compatibility with the old behavior.@ambv What do you think? Let me know if there's a better forum in which to discuss.