diff --git a/base/io.jl b/base/io.jl index eb9eff598f712..e15551cfbdfa7 100644 --- a/base/io.jl +++ b/base/io.jl @@ -1023,6 +1023,8 @@ eltype(::Type{<:EachLine}) = String IteratorSize(::Type{<:EachLine}) = SizeUnknown() +isdone(itr::EachLine, state...) = eof(itr.stream) + struct ReadEachIterator{T, IOT <: IO} stream::IOT end diff --git a/test/read.jl b/test/read.jl index b63658d225111..b7e8c2260a4f9 100644 --- a/test/read.jl +++ b/test/read.jl @@ -617,3 +617,12 @@ let p = Pipe() wait(t) close(p) end + +@testset "issue #27412" begin + itr = eachline(IOBuffer("a")) + @test !isempty(itr) + # check that the earlier isempty did not consume the iterator + @test !isempty(itr) + first(itr) # consume the iterator + @test isempty(itr) # now it is empty +end