-
Notifications
You must be signed in to change notification settings - Fork 26
fix eof issues and add tests #170
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3aa6c97
fix eof issues and add tests
nhz2 c74b74d
Throw EOFError if closed
nhz2 1a2c270
Update tests for EOFError
nhz2 7b358b9
remove extra if
nhz2 803bf22
clean up other uses of ready_to_read!
nhz2 3b1d67a
undo suggestion
nhz2 6f41083
better error messages in test codec
nhz2 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.
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.
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.
This should be implied by eof
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 change means an
EOFErroris thrown when reading a byte from a closed stream.This seems to match what happens with
IOStreamBut doesn't match with what
IOBufferdoes: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.
True, though I think
eofcould optionally throw a state-exception in that case also sometimes. The ambiguity occurs when a stream is ambiguously readable or writable, which sometimes cannot be avoided. So seekable files usuallycloseboth ends at once (and eof is a transient condition, which changes to an error after calling close), whereas (non-seekable) streams the eof is a property of reading and isopen is a property of writingThere 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'm undoing the change because I like how
IOBufferis handling this better thanIOStream.For example, I think
read(io, String)after close should error instead of returning an empty string: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.
Yes, but that is already eof’s job to throw when there is a state violation, so it should not be necessary for read to also redundantly check
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 would break this test that was added in #32:
TranscodingStreams.jl/test/codecnoop.jl
Lines 283 to 287 in 92adcd8
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.
I agree that eof should throw if the stream is not in a readable state.
However this seems like a breaking change, so I will split this PR into smaller parts, and add the eof changes in v0.11 for v0.11 I would also like to fix #93, #109 and remove the
seekendimplementation.