Skip to content

isreadable is underdocumented and inconsistently implemented #57942

@jakobnissen

Description

@jakobnissen

What does isreadable mean? The documentation states:

Return false if the specified IO object is not readable.

Well, that's unhelpful.
Here are some plausible meanings of isreadable(io::MyIO):

  1. You can read from io, and get some bytes from doing it.
  2. You can call read on io, but it might be EOF, so you might not get any bytes

The unfortunate current situation is that DevNull follows 1, and IOStream and IOBuffer follows 2:

julia> #devnull acts as a readable, but EOF stream
       isreadable(devnull)
false 

julia> read(devnull)
UInt8[]

julia> buf = IOBuffer(); isreadable(buf)
true

julia> close(buf); isreadable(buf)
false

Probably this is just wrong for devnull and should be changed. I'll make a PR

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