-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
isempty(::EachLine)
expends a line
#27412
Comments
When discussing this on slack more broadly. Such a trait could be tri-valued
And that trait would determine which default implementation of |
Another defensive approach is to make About |
Another benefit is that this allows a trivial implementation of |
isempty(::EachLine)
should probably do a defensive copyisempty(::EachLine)
expends a line
To copy the state of a stateful iterator, Just a bandaid, but we could add an |
With this method, `isempty` won't consume values from the iterator (See JuliaLang#27412).
This bit me again today. What other stateful iterators are there in Julia? Maybe we can just add bandaids for most of them? From the docs, it looks like we should just add Agree with traits or similar so code can identify stateful iterators. |
With this method, `isempty` won't consume values from the iterator (See JuliaLang#27412).
Fixed by #39562 in ede6486 |
This prevents `isempty` and friends from advancing the iterator when they shouldn't. Note: `collect(readeach(io, T))` can throw an exception if `io` isn't a multiple of the right size. `isempty` will still return `false`, even if the next call to `iterate` will throw an exception. Similar to: JuliaLang#27412
This prevents `isempty` and friends from advancing the iterator when they shouldn't. Note: `collect(readeach(io, T))` can throw an exception if `io` isn't a multiple of the right size. `isempty` will still return `false`, even if the next call to `iterate` will throw an exception. Similar to: #27412
With this method, `isempty` won't consume values from the iterator (See JuliaLang#27412).
This prevents `isempty` and friends from advancing the iterator when they shouldn't. Note: `collect(readeach(io, T))` can throw an exception if `io` isn't a multiple of the right size. `isempty` will still return `false`, even if the next call to `iterate` will throw an exception. Similar to: JuliaLang#27412
With this method, `isempty` won't consume values from the iterator (See JuliaLang#27412).
This prevents `isempty` and friends from advancing the iterator when they shouldn't. Note: `collect(readeach(io, T))` can throw an exception if `io` isn't a multiple of the right size. `isempty` will still return `false`, even if the next call to `iterate` will throw an exception. Similar to: JuliaLang#27412
Eachline is (almost?) always a stateful iterator.
This means the default
isempty
which callediterate
will consume a line if there is one to consume.Sometimes (always?) in the use of Eachline (but not more generally), a defensive deepcopy can protect against that.
This is in 0.7
I feel like I (or someone else) opened a similar issue for this in 0.6
but I could be mis-remembering.
Downside of this fix, is that I'm not sure it works for all uses of Eachline.
It works for IOBuffer (and I think IOStream) because there is a pointer integer that is copied.
But if it was consuming unbuffered network data, then not possible because what is gone is gone.
(idk that it is possible to access unbuffered network data in julia)
Minimum Breaking Example
Defensive-copy work-around
The text was updated successfully, but these errors were encountered: