Skip to content

Proposal: Allow DevNull to be used in redirect_stdout #22879

@sbromberger

Description

@sbromberger

Following up on #12050 (comment),

I would like to propose that we change redirect_stdout to allow this:

julia> redirect_stdout(DevNull)
ERROR: MethodError: no method matching redirect_stdout(::Base.DevNullStream)
Closest candidates are:
  redirect_stdout() at stream.jl:1034
  redirect_stdout(::Union{Base.LibuvStream, IOStream}) at stream.jl:1028
  redirect_stdout(::Function, ::Any) at stream.jl:1082

Right now,

DevNull <: DevNullStream <: IO <: Any,
open("/tmp/foo", "w") <: IOStream <: IO <: Any,
STDOUT <: TTY <: LibuvStream <: IO <: Any

The latter two are allowed with redirect_stdout per the second method listed, but DevNull isn't.

(Is there a reason that redirect_stdout can't accept IO? That would resolve this issue and make things more consistent.)

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