Skip to content

mark/reset broken for BufferStream #24465

@samoconnor

Description

@samoconnor

mark/reset works for IOBuffer:

julia> io = IOBuffer(UInt8[1,2,3])

julia> mark(io)
julia> readavailable(io) == [1,2,3]
true

julia> reset(io)
julia> readavailable(io) == [1,2,3]
true

... but not for BufferStream:

Version 0.7.0-DEV.2098 (2017-10-10 11:37 UTC)

julia> io = BufferStream()
julia> write(io, UInt8[1,2,3])

julia> mark(io)
julia> readavailable(io) == [1,2,3]
true

julia> reset(io)
ERROR: ArgumentError: Base.GenericIOBuffer{Array{UInt8,1}} not marked

 @which readavailable(io)
readavailable(this::Base.LibuvStream) in Base at stream.jl:780

I think this is because readavailable(::Base.LibuvStream) calls take! (and take! does unmark).

See also pervious question about why the code has BufferStream <: LibuvStream but the comments says BufferStream <: IO.

If I cheat and read from io.buffer it works...

julia> io = BufferStream()
julia> write(io, UInt8[1,2,3])
julia> mark(io)
julia> readavailable(io.buffer) == [1,2,3]
true
julia> reset(io)
julia> readavailable(io.buffer) == [1,2,3]
true

Metadata

Metadata

Assignees

No one assigned

    Labels

    ioInvolving the I/O subsystem: libuv, read, write, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions