-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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-22908: Add seek and tell functionality to ZipExtFile #4966
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f986819
bpo-22908: Add seek and tell functionality to ZipExtFile
jjolly 4f60ae5
Added blurb
jjolly 8cb03b0
bpo-22908: Optimized backward seek still in _readbuffer
jjolly 384a9e3
bpo-22908: Reads chunk of file during advancing seek pointer
jjolly 418d453
bpo-22908: Change seek from_what argument to whence
jjolly 41536e4
bpo-22908: Added test_seek_tell to Lib/test/test_zipfile.py
jjolly 92847a3
bpo-22908: Added seek and tell to list of functions made available to…
jjolly eca9b32
bpo-22908: Removed trailing whitespace in doc
jjolly 1ba5aa9
disallow whence values other than 0, 1, or 2
gpshead e8af6fb
simplify and correct NEWS wording.
gpshead 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 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
4 changes: 4 additions & 0 deletions
4
Misc/NEWS.d/next/Library/2017-12-21-22-00-11.bpo-22908.cVm89I.rst
This file contains 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,4 @@ | ||
Added seek and rest to the ZipExtFile class. This only works if the file | ||
object used to open the zipfile is seekable. This change is the first | ||
iteration of this feature and can easily be optimized by considering the | ||
_readbuffer. |
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.
I would recommend matching the signature of the same method in the
io
module:seek(self, pos, whence=0)
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.
I chose offset because I can better differentiate between offset value (relative values) and position values (absolute values). Also, according to the official documentation "offset" should be the first argument for seek (although there is no consensus when I search through the cpython source). https://docs.python.org/3/library/io.html#io.IOBase.seek
I agree with changing "from_what" to "whence". The former always felt awkward to me. Thank you for the suggestion
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.
It seems like older modules use
pos
(e.g. mmap), and the more recent io ABCs useoffset
. This should be fine, and I expect people to pass the parameter as a positional argument anyway.