diff --git a/DISTRIBUTING.md b/DISTRIBUTING.md index a159188e8f32c..e711f255eeed5 100644 --- a/DISTRIBUTING.md +++ b/DISTRIBUTING.md @@ -375,7 +375,7 @@ for result in eachrow(results) end ``` -This will write color-coded lines to STDOUT. +This will write color-coded lines to `stdout`. All lines in red must be investigated as they signify potential breakages caused by the backport version. Lines in yellow should be looked into since it means a package ran on one version but diff --git a/NEWS.md b/NEWS.md index 650a8fc820839..99cd8421ed7a2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1068,7 +1068,8 @@ Deprecated or removed * The fallback method `^(x, p::Integer)` is deprecated. If your type relied on this definition, add a method such as `^(x::MyType, p::Integer) = Base.power_by_squaring(x, p)` ([#23332]). - * `DevNull` has been renamed to `devnull` ([#25786]). + * `DevNull`, `STDIN`, `STDOUT`, and `STDERR` have been renamed to `devnull`, `stdin`, `stdout`, + and `stderr`, respectively ([#25786]). * `wait` and `fetch` on `Task` now resemble the interface of `Future` diff --git a/base/boot.jl b/base/boot.jl index bc336015ab1a0..75070ddf496d7 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -430,8 +430,8 @@ atdoc!(λ) = global atdoc = λ abstract type IO end struct CoreSTDOUT <: IO end struct CoreSTDERR <: IO end -const STDOUT = CoreSTDOUT() -const STDERR = CoreSTDERR() +const stdout = CoreSTDOUT() +const stderr = CoreSTDERR() io_pointer(::CoreSTDOUT) = Intrinsics.pointerref(Intrinsics.cglobal(:jl_uv_stdout, Ptr{Cvoid}), 1, 1) io_pointer(::CoreSTDERR) = Intrinsics.pointerref(Intrinsics.cglobal(:jl_uv_stderr, Ptr{Cvoid}), 1, 1) @@ -455,9 +455,9 @@ print(io::IO, @nospecialize(x), @nospecialize a...) = (print(io, x); print(io, a println(io::IO) = (write(io, 0x0a); nothing) # 0x0a = '\n' println(io::IO, @nospecialize x...) = (print(io, x...); println(io)) -show(@nospecialize a) = show(STDOUT, a) -print(@nospecialize a...) = print(STDOUT, a...) -println(@nospecialize a...) = println(STDOUT, a...) +show(@nospecialize a) = show(stdout, a) +print(@nospecialize a...) = print(stdout, a...) +println(@nospecialize a...) = println(stdout, a...) struct GeneratedFunctionStub gen diff --git a/base/client.jl b/base/client.jl index e663d61b44332..9fe0eb87bee7a 100644 --- a/base/client.jl +++ b/base/client.jl @@ -165,7 +165,7 @@ function display_error(io::IO, er, bt) showerror(IOContext(io, :limit => true), er, bt) println(io) end -display_error(er, bt) = display_error(STDERR, er, bt) +display_error(er, bt) = display_error(stderr, er, bt) display_error(er) = display_error(er, []) function eval_user_input(@nospecialize(ast), show_value::Bool) @@ -189,7 +189,7 @@ function eval_user_input(@nospecialize(ast), show_value::Bool) try invokelatest(display, value) catch err - println(STDERR, "Evaluation succeeded, but an error occurred while showing value of type ", typeof(value), ":") + println(stderr, "Evaluation succeeded, but an error occurred while showing value of type ", typeof(value), ":") rethrow(err) end println() @@ -198,17 +198,17 @@ function eval_user_input(@nospecialize(ast), show_value::Bool) break catch err if errcount > 0 - println(STDERR, "SYSTEM: show(lasterr) caused an error") + println(stderr, "SYSTEM: show(lasterr) caused an error") end errcount, lasterr = errcount+1, err if errcount > 2 - println(STDERR, "WARNING: it is likely that something important is broken, and Julia will not be able to continue normally") + println(stderr, "WARNING: it is likely that something important is broken, and Julia will not be able to continue normally") break end bt = catch_backtrace() end end - isa(STDIN, TTY) && println() + isa(stdin, TTY) && println() nothing end @@ -333,7 +333,7 @@ function exec_options(opts) end repl |= is_interactive if repl - interactiveinput = isa(STDIN, TTY) + interactiveinput = isa(stdin, TTY) if interactiveinput global is_interactive = true banner = (opts.banner != 0) # --banner!=no @@ -374,8 +374,8 @@ function __atreplinit(repl) try f(repl) catch err - showerror(STDERR, err) - println(STDERR) + showerror(stderr, err) + println(stderr) end end end @@ -390,7 +390,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_fil if interactive && isassigned(REPL_MODULE_REF) invokelatest(REPL_MODULE_REF[]) do REPL term_env = get(ENV, "TERM", @static Sys.iswindows() ? "" : "dumb") - term = REPL.Terminals.TTYTerminal(term_env, STDIN, STDOUT, STDERR) + term = REPL.Terminals.TTYTerminal(term_env, stdin, stdout, stderr) color_set || (global have_color = REPL.Terminals.hascolor(term)) banner && REPL.banner(term, term) if term.term_type == "dumb" @@ -412,7 +412,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_fil @warn "REPL provider not available: using basic fallback" end banner && Base.banner() - let input = STDIN + let input = stdin if isa(input, File) || isa(input, IOStream) # for files, we can slurp in the whole thing at once ex = parse_input_line(read(input, String)) @@ -430,7 +430,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_fil while isopen(input) || !eof(input) if interactive print("julia> ") - flush(STDOUT) + flush(stdout) end eval_user_input(parse_input_line(input), true) end diff --git a/base/clipboard.jl b/base/clipboard.jl index deec50d475ad0..7aa6d71ef9ef6 100644 --- a/base/clipboard.jl +++ b/base/clipboard.jl @@ -4,7 +4,7 @@ if Sys.isapple() function clipboard(x) - open(pipeline(`pbcopy`, stderr=STDERR), "w") do io + open(pipeline(`pbcopy`, stderr=stderr), "w") do io print(io, x) end end @@ -43,7 +43,7 @@ elseif Sys.islinux() || Sys.KERNEL === :FreeBSD if cmd === nothing error("unexpected clipboard command: $c") end - open(pipeline(cmd, stderr=STDERR), "w") do io + open(pipeline(cmd, stderr=stderr), "w") do io print(io, x) end end @@ -53,7 +53,7 @@ elseif Sys.islinux() || Sys.KERNEL === :FreeBSD if cmd === nothing error("unexpected clipboard command: $c") end - read(pipeline(cmd, stderr=STDERR), String) + read(pipeline(cmd, stderr=stderr), String) end elseif Sys.iswindows() diff --git a/base/compiler/bootstrap.jl b/base/compiler/bootstrap.jl index 04796b39c58cf..1a19429c8155a 100644 --- a/base/compiler/bootstrap.jl +++ b/base/compiler/bootstrap.jl @@ -15,7 +15,7 @@ let fs = Any[typeinf_ext, typeinf, typeinf_edge, pure_eval_call], x = T_IFUNC[i] push!(fs, x[3]) else - println(STDERR, "WARNING: tfunc missing for ", reinterpret(IntrinsicFunction, Int32(i))) + println(stderr, "WARNING: tfunc missing for ", reinterpret(IntrinsicFunction, Int32(i))) end end for f in fs diff --git a/base/compiler/compiler.jl b/base/compiler/compiler.jl index d45181a2be186..c4d09ca941e52 100644 --- a/base/compiler/compiler.jl +++ b/base/compiler/compiler.jl @@ -4,7 +4,7 @@ getfield(getfield(Main, :Core), :eval)(getfield(Main, :Core), :(baremodule Compi using Core.Intrinsics, Core.IR -import Core: print, println, show, write, unsafe_write, STDOUT, STDERR, +import Core: print, println, show, write, unsafe_write, stdout, stderr, _apply, svec, apply_type, Builtin, IntrinsicFunction, MethodInstance const getproperty = getfield diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index fda39b098f6bd..75c0ff16b327b 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -3733,7 +3733,7 @@ macro check_ast(ctx, ex) println("Code:") println(ctx.sv.src) println("Value Info Map:") - show_info(STDOUT, ctx.infomap, ctx) + show_info(stdout, ctx.infomap, ctx) ccall(:abort, Union{}, ()) end end diff --git a/base/compiler/validation.jl b/base/compiler/validation.jl index ed18ec973b4c9..2dadd460652a7 100644 --- a/base/compiler/validation.jl +++ b/base/compiler/validation.jl @@ -59,10 +59,10 @@ function validate_code_in_debug_mode(linfo::MethodInstance, src::CodeInfo, kind: if !isempty(errors) for e in errors if linfo.def isa Method - println(STDERR, "WARNING: Encountered invalid ", kind, " code for method ", + println(stderr, "WARNING: Encountered invalid ", kind, " code for method ", linfo.def, ": ", e) else - println(STDERR, "WARNING: Encountered invalid ", kind, " code for top level expression in ", + println(stderr, "WARNING: Encountered invalid ", kind, " code for top level expression in ", linfo.def, ": ", e) end end diff --git a/base/coreio.jl b/base/coreio.jl index 7f2f22d73d882..e901cdec10e39 100644 --- a/base/coreio.jl +++ b/base/coreio.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -print(xs...) = print(STDOUT::IO, xs...) -println(xs...) = println(STDOUT::IO, xs...) +print(xs...) = print(stdout::IO, xs...) +println(xs...) = println(stdout::IO, xs...) println(io::IO) = print(io, '\n') struct DevNullStream <: IO end @@ -26,6 +26,6 @@ let CoreIO = Union{Core.CoreSTDOUT, Core.CoreSTDERR} unsafe_write(io::CoreIO, x::Ptr{UInt8}, nb::UInt) = Core.unsafe_write(io, x, nb) end -STDIN = devnull -STDOUT = Core.STDOUT -STDERR = Core.STDERR +stdin = devnull +stdout = Core.stdout +stderr = Core.stderr diff --git a/base/deprecated.jl b/base/deprecated.jl index 78126653430ee..c8a1310306144 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -960,14 +960,14 @@ function info(io::IO, msg...; prefix="INFO: ") print(io, String(take!(buf))) return end -info(msg...; prefix="INFO: ") = info(STDERR, msg..., prefix=prefix) +info(msg...; prefix="INFO: ") = info(stderr, msg..., prefix=prefix) # print a warning only once const have_warned = Set() warn_once(io::IO, msg...) = warn(io, msg..., once=true) -warn_once(msg...) = warn(STDERR, msg..., once=true) +warn_once(msg...) = warn(stderr, msg..., once=true) """ warn([io, ] msg..., [prefix="WARNING: ", once=false, key=nothing, bt=nothing, filename=nothing, lineno::Int=0]) @@ -1017,19 +1017,19 @@ julia> warn("Beep Beep") WARNING: Beep Beep ``` """ -warn(msg...; kw...) = warn(STDERR, msg...; kw...) +warn(msg...; kw...) = warn(stderr, msg...; kw...) warn(io::IO, err::Exception; prefix="ERROR: ", kw...) = warn(io, sprint(showerror, err), prefix=prefix; kw...) warn(err::Exception; prefix="ERROR: ", kw...) = - warn(STDERR, err, prefix=prefix; kw...) + warn(stderr, err, prefix=prefix; kw...) info(io::IO, err::Exception; prefix="ERROR: ", kw...) = info(io, sprint(showerror, err), prefix=prefix; kw...) info(err::Exception; prefix="ERROR: ", kw...) = - info(STDERR, err, prefix=prefix; kw...) + info(stderr, err, prefix=prefix; kw...) # issue #25082 @deprecate_binding Void Nothing @@ -1395,6 +1395,9 @@ end # Issue #25786 @deprecate_binding DevNull devnull +@deprecate_binding STDIN stdin +@deprecate_binding STDOUT stdout +@deprecate_binding STDERR stderr # PR 25062 @deprecate(link_pipe(pipe; julia_only_read = true, julia_only_write = true), diff --git a/base/errorshow.jl b/base/errorshow.jl index baec065806b11..fb260ffb0e99c 100644 --- a/base/errorshow.jl +++ b/base/errorshow.jl @@ -290,7 +290,7 @@ function showerror_ambiguous(io::IO, meth, f, args) end #Show an error by directly calling jl_printf. -#Useful in Base submodule __init__ functions where STDERR isn't defined yet. +#Useful in Base submodule __init__ functions where stderr isn't defined yet. function showerror_nostdio(err, msg::AbstractString) stderr_stream = ccall(:jl_stderr_stream, Ptr{Cvoid}, ()) ccall(:jl_printf, Cint, (Ptr{Cvoid},Cstring), stderr_stream, msg) diff --git a/base/exports.jl b/base/exports.jl index 80e3ac6fba301..3aa1dc63c9995 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -134,9 +134,9 @@ export ENV, LOAD_PATH, PROGRAM_FILE, - STDERR, - STDIN, - STDOUT, + stderr, + stdin, + stdout, VERSION, devnull, diff --git a/base/initdefs.jl b/base/initdefs.jl index ea456907a17a8..9de4daec2b1dd 100644 --- a/base/initdefs.jl +++ b/base/initdefs.jl @@ -149,8 +149,8 @@ function _atexit() try f() catch err - show(STDERR, err) - println(STDERR) + show(stderr, err) + println(stderr) end end end diff --git a/base/io.jl b/base/io.jl index 8e0f6e66bd3e3..6f1ed0b654b77 100644 --- a/base/io.jl +++ b/base/io.jl @@ -326,10 +326,10 @@ julia> rm("my_file.txt") readuntil(filename::AbstractString, args...; kw...) = open(io->readuntil(io, args...; kw...), filename) """ - readline(io::IO=STDIN; keep::Bool=false) + readline(io::IO=stdin; keep::Bool=false) readline(filename::AbstractString; keep::Bool=false) -Read a single line of text from the given I/O stream or file (defaults to `STDIN`). +Read a single line of text from the given I/O stream or file (defaults to `stdin`). When reading from a file, the text is assumed to be encoded in UTF-8. Lines in the input end with `'\\n'` or `"\\r\\n"` or the end of an input stream. When `keep` is false (as it is by default), these trailing newline characters are removed from the @@ -362,7 +362,7 @@ function readline(filename::AbstractString; chomp=nothing, keep::Bool=false) end end -function readline(s::IO=STDIN; chomp=nothing, keep::Bool=false) +function readline(s::IO=stdin; chomp=nothing, keep::Bool=false) if chomp !== nothing keep = !chomp depwarn("The `chomp=$chomp` argument to `readline` is deprecated in favor of `keep=$keep`.", :readline) @@ -379,7 +379,7 @@ function readline(s::IO=STDIN; chomp=nothing, keep::Bool=false) end """ - readlines(io::IO=STDIN; keep::Bool=false) + readlines(io::IO=stdin; keep::Bool=false) readlines(filename::AbstractString; keep::Bool=false) Read all lines of an I/O stream or a file as a vector of strings. Behavior is @@ -411,7 +411,7 @@ function readlines(filename::AbstractString; kw...) readlines(f; kw...) end end -readlines(s=STDIN; kw...) = collect(eachline(s; kw...)) +readlines(s=stdin; kw...) = collect(eachline(s; kw...)) ## byte-order mark, ntoh & hton ## @@ -839,12 +839,12 @@ struct EachLine ondone::Function keep::Bool - EachLine(stream::IO=STDIN; ondone::Function=()->nothing, keep::Bool=false) = + EachLine(stream::IO=stdin; ondone::Function=()->nothing, keep::Bool=false) = new(stream, ondone, keep) end """ - eachline(io::IO=STDIN; keep::Bool=false) + eachline(io::IO=stdin; keep::Bool=false) eachline(filename::AbstractString; keep::Bool=false) Create an iterable `EachLine` object that will yield each line from an I/O stream @@ -868,7 +868,7 @@ JuliaLang is a GitHub organization. It has many members. julia> rm("my_file.txt"); ``` """ -function eachline(stream::IO=STDIN; chomp=nothing, keep::Bool=false) +function eachline(stream::IO=stdin; chomp=nothing, keep::Bool=false) if chomp !== nothing keep = !chomp depwarn("The `chomp=$chomp` argument to `eachline` is deprecated in favor of `keep=$keep`.", :eachline) diff --git a/base/libuv.jl b/base/libuv.jl index 2cdcb5c961348..be8646e65b831 100644 --- a/base/libuv.jl +++ b/base/libuv.jl @@ -100,28 +100,28 @@ function reinit_stdio() global uv_jl_timercb = cfunction(uv_timercb, Cvoid, Tuple{Ptr{Cvoid}}) global uv_eventloop = ccall(:jl_global_event_loop, Ptr{Cvoid}, ()) - global STDIN = init_stdio(ccall(:jl_stdin_stream, Ptr{Cvoid}, ())) - global STDOUT = init_stdio(ccall(:jl_stdout_stream, Ptr{Cvoid}, ())) - global STDERR = init_stdio(ccall(:jl_stderr_stream, Ptr{Cvoid}, ())) + global stdin = init_stdio(ccall(:jl_stdin_stream, Ptr{Cvoid}, ())) + global stdout = init_stdio(ccall(:jl_stdout_stream, Ptr{Cvoid}, ())) + global stderr = init_stdio(ccall(:jl_stderr_stream, Ptr{Cvoid}, ())) end """ - STDIN + stdin Global variable referring to the standard input stream. """ -:STDIN +:stdin """ - STDOUT + stdout Global variable referring to the standard out stream. """ -:STDOUT +:stdout """ - STDERR + stderr Global variable referring to the standard error stream. """ -:STDERR +:stderr diff --git a/base/loading.jl b/base/loading.jl index ee03cc24b2a16..4df742518613e 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1099,8 +1099,8 @@ evalfile(path::AbstractString, args::Vector) = evalfile(path, String[args...]) function create_expr_cache(input::String, output::String, concrete_deps::typeof(_concrete_dependencies), uuid::Union{Nothing,UUID}) rm(output, force=true) # Remove file if it exists code_object = """ - while !eof(STDIN) - code = readuntil(STDIN, '\\0') + while !eof(stdin) + code = readuntil(stdin, '\\0') eval(Main, Meta.parse(code)) end """ @@ -1108,8 +1108,8 @@ function create_expr_cache(input::String, output::String, concrete_deps::typeof( --output-ji $output --output-incremental=yes --startup-file=no --history-file=no --warn-overwrite=yes --color=$(have_color ? "yes" : "no") - --eval $code_object`), stderr=STDERR), - "w", STDOUT) + --eval $code_object`), stderr=stderr), + "w", stdout) in = io.in try write(in, """ diff --git a/base/logging.jl b/base/logging.jl index 83d1a3ed15f7a..6bcb82cdf6156 100644 --- a/base/logging.jl +++ b/base/logging.jl @@ -335,10 +335,10 @@ end try # Give up and write to STDERR, in three independent calls to # increase the odds of it getting through. - print(STDERR, "Exception handling log message: ") - println(STDERR, err) - println(STDERR, " module=$_module file=$filepath line=$line") - println(STDERR, " Second exception: ", err2) + print(stderr, "Exception handling log message: ") + println(stderr, err) + println(stderr, " module=$_module file=$filepath line=$line") + println(stderr, " Second exception: ", err2) catch end end @@ -451,7 +451,7 @@ current_logger() = current_logstate().logger #------------------------------------------------------------------------------- # SimpleLogger """ - SimpleLogger(stream=STDERR, min_level=Info) + SimpleLogger(stream=stderr, min_level=Info) Simplistic logger for logging all messages with level greater than or equal to `min_level` to `stream`. @@ -461,7 +461,7 @@ struct SimpleLogger <: AbstractLogger min_level::LogLevel message_limits::Dict{Any,Int} end -SimpleLogger(stream::IO=STDERR, level=Info) = SimpleLogger(stream, level, Dict{Any,Int}()) +SimpleLogger(stream::IO=stderr, level=Info) = SimpleLogger(stream, level, Dict{Any,Int}()) shouldlog(logger::SimpleLogger, level, _module, group, id) = get(logger.message_limits, id, 1) > 0 diff --git a/base/meta.jl b/base/meta.jl index 866ec0c2428f7..36683fc569930 100644 --- a/base/meta.jl +++ b/base/meta.jl @@ -23,7 +23,7 @@ isexpr(ex, head, n::Int) = isexpr(ex, head) && length(ex.args) == n # ---- show_sexpr: print an AST as an S-expression ---- -show_sexpr(ex) = show_sexpr(STDOUT, ex) +show_sexpr(ex) = show_sexpr(stdout, ex) show_sexpr(io::IO, ex) = show_sexpr(io, ex, 0) show_sexpr(io::IO, ex, indent::Int) = show(io, ex) diff --git a/base/multimedia.jl b/base/multimedia.jl index d988d4da2e5db..707ddcda98c01 100644 --- a/base/multimedia.jl +++ b/base/multimedia.jl @@ -251,7 +251,7 @@ function popdisplay(d::AbstractDisplay) end function reinit_displays() empty!(displays) - pushdisplay(TextDisplay(STDOUT)) + pushdisplay(TextDisplay(stdout)) end xdisplayable(D::AbstractDisplay, args...) = applicable(display, D, args...) @@ -263,15 +263,15 @@ xdisplayable(D::AbstractDisplay, args...) = applicable(display, D, args...) display(d::AbstractDisplay, mime, x) AbstractDisplay `x` using the topmost applicable display in the display stack, typically using the -richest supported multimedia output for `x`, with plain-text [`STDOUT`](@ref) output as a fallback. +richest supported multimedia output for `x`, with plain-text [`stdout`](@ref) output as a fallback. The `display(d, x)` variant attempts to display `x` on the given display `d` only, throwing a [`MethodError`](@ref) if `d` cannot display objects of this type. -In general, you cannot assume that `display` output goes to `STDOUT` (unlike [`print(x)`](@ref) or +In general, you cannot assume that `display` output goes to `stdout` (unlike [`print(x)`](@ref) or [`show(x)`](@ref)). For example, `display(x)` may open up a separate window with an image. `display(x)` means "show `x` in the best way you can for the current output device(s)." -If you want REPL-like text output that is guaranteed to go to `STDOUT`, use -[`show(STDOUT, "text/plain", x)`](@ref) instead. +If you want REPL-like text output that is guaranteed to go to `stdout`, use +[`show(stdout, "text/plain", x)`](@ref) instead. There are also two variants with a `mime` argument (a MIME type string, such as `"image/png"`), which attempt to display `x` using the requested MIME type *only*, throwing diff --git a/base/printf.jl b/base/printf.jl index 8bfefc8e77c11..aa13e798975b9 100644 --- a/base/printf.jl +++ b/base/printf.jl @@ -1198,7 +1198,7 @@ end macro printf(args...) isempty(args) && throw(ArgumentError("@printf: called with no arguments")) if isa(args[1], AbstractString) || is_str_expr(args[1]) - _printf("@printf", :STDOUT, args[1], args[2:end]) + _printf("@printf", :stdout, args[1], args[2:end]) else (length(args) >= 2 && (isa(args[2], AbstractString) || is_str_expr(args[2]))) || throw(ArgumentError("@printf: first or second argument must be a format string")) diff --git a/base/process.jl b/base/process.jl index 4e41aaac8c868..e9a76b1a10f7f 100644 --- a/base/process.jl +++ b/base/process.jl @@ -562,7 +562,7 @@ function eachline(cmd::AbstractCmd; chomp=nothing, keep::Bool=false) depwarn("The `chomp=$chomp` argument to `eachline` is deprecated in favor of `keep=$keep`.", :eachline) end _stdout = Pipe() - processes = spawn(cmd, (devnull, _stdout, STDERR)) + processes = spawn(cmd, (devnull, _stdout, stderr)) close(_stdout.in) out = _stdout.out # implicitly close after reading lines, since we opened @@ -585,13 +585,13 @@ function open(cmds::AbstractCmd, mode::AbstractString="r", other::Redirectable=d other === devnull || throw(ArgumentError("no other stream for mode rw+")) in = Pipe() out = Pipe() - processes = spawn(cmds, (in,out,STDERR)) + processes = spawn(cmds, (in,out,stderr)) close(in.out) close(out.in) elseif mode == "r" in = other out = Pipe() - processes = spawn(cmds, (in,out,STDERR)) + processes = spawn(cmds, (in,out,stderr)) close(out.in) if isa(processes, ProcessChain) # for open(cmd) deprecation processes = ProcessChain(processes, :out) @@ -601,7 +601,7 @@ function open(cmds::AbstractCmd, mode::AbstractString="r", other::Redirectable=d elseif mode == "w" in = Pipe() out = other - processes = spawn(cmds, (in,out,STDERR)) + processes = spawn(cmds, (in,out,stderr)) close(in.out) if isa(processes, ProcessChain) # for open(cmd) deprecation processes = ProcessChain(processes, :in) diff --git a/base/show.jl b/base/show.jl index 12ad72f6f7760..098978a761ed4 100644 --- a/base/show.jl +++ b/base/show.jl @@ -245,9 +245,9 @@ julia> String(take!(io)) ``` ```jldoctest -julia> print(IOContext(STDOUT, :compact => false), 1.12341234) +julia> print(IOContext(stdout, :compact => false), 1.12341234) 1.12341234 -julia> print(IOContext(STDOUT, :compact => true), 1.12341234) +julia> print(IOContext(stdout, :compact => true), 1.12341234) 1.12341 ``` @@ -261,9 +261,9 @@ julia> function f(io::IO) end f (generic function with 1 method) -julia> f(STDOUT) +julia> f(stdout) loooooong -julia> f(IOContext(STDOUT, :short => true)) +julia> f(IOContext(stdout, :short => true)) short ``` """ @@ -309,7 +309,7 @@ Write an informative text representation of a value to the current output stream should overload `show(io, x)` where the first argument is a stream. The representation used by `show` generally includes Julia-specific formatting and type information. """ -show(x) = show(STDOUT::IO, x) +show(x) = show(stdout::IO, x) show(io::IO, @nospecialize(x)) = show_default(io, x) @@ -529,7 +529,7 @@ function show_supertypes(io::IO, typ::DataType) end end -show_supertypes(typ::DataType) = show_supertypes(STDOUT, typ) +show_supertypes(typ::DataType) = show_supertypes(stdout, typ) """ @show @@ -1761,7 +1761,7 @@ DeeplyNested 1: DeeplyNested ``` """ -dump(arg; maxdepth=DUMP_DEFAULT_MAXDEPTH) = dump(IOContext(STDOUT::IO, :limit => true), arg; maxdepth=maxdepth) +dump(arg; maxdepth=DUMP_DEFAULT_MAXDEPTH) = dump(IOContext(stdout::IO, :limit => true), arg; maxdepth=maxdepth) """ @@ -1951,7 +1951,7 @@ end showcompact(io::IO, x) Show a compact representation of a value to `io`. If `io` is not specified, the -default is to print to [`STDOUT`](@ref). +default is to print to [`stdout`](@ref). This is used for printing array elements without repeating type information (which would be redundant with that printed once for the whole array), and without line breaks inside @@ -1971,7 +1971,7 @@ julia> showcompact(A) [1.0 2.0; 3.0 4.0] ``` """ -showcompact(x) = showcompact(STDOUT, x) +showcompact(x) = showcompact(stdout, x) function showcompact(io::IO, x) if get(io, :compact, false) show(io, x) @@ -1995,8 +1995,8 @@ function print_bit_chunk(io::IO, c::UInt64, l::Integer = 64) end end -print_bit_chunk(c::UInt64, l::Integer) = print_bit_chunk(STDOUT, c, l) -print_bit_chunk(c::UInt64) = print_bit_chunk(STDOUT, c) +print_bit_chunk(c::UInt64, l::Integer) = print_bit_chunk(stdout, c, l) +print_bit_chunk(c::UInt64) = print_bit_chunk(stdout, c) function bitshow(io::IO, B::BitArray) isempty(B) && return @@ -2008,6 +2008,6 @@ function bitshow(io::IO, B::BitArray) l = _mod64(length(B)-1) + 1 print_bit_chunk(io, Bc[end], l) end -bitshow(B::BitArray) = bitshow(STDOUT, B) +bitshow(B::BitArray) = bitshow(stdout, B) bitstring(B::BitArray) = sprint(bitshow, B) diff --git a/base/stream.jl b/base/stream.jl index 502bfcab8e79f..95a554007e76c 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -391,7 +391,7 @@ julia> withenv("LINES" => 30, "COLUMNS" => 100) do To get your TTY size, ```julia -julia> displaysize(STDOUT) +julia> displaysize(stdout) (34, 147) ``` """ @@ -1056,9 +1056,9 @@ function _fd(x::Union{LibuvStream, LibuvServer}) end for (x, writable, unix_fd, c_symbol) in - ((:STDIN, false, 0, :jl_uv_stdin), - (:STDOUT, true, 1, :jl_uv_stdout), - (:STDERR, true, 2, :jl_uv_stderr)) + ((:stdin, false, 0, :jl_uv_stdin), + (:stdout, true, 1, :jl_uv_stdout), + (:stderr, true, 2, :jl_uv_stderr)) f = Symbol("redirect_", lowercase(string(x))) _f = Symbol("_", f) @eval begin @@ -1091,12 +1091,12 @@ end """ redirect_stdout([stream]) -> (rd, wr) -Create a pipe to which all C and Julia level [`STDOUT`](@ref) output +Create a pipe to which all C and Julia level [`stdout`](@ref) output will be redirected. Returns a tuple `(rd, wr)` representing the pipe ends. -Data written to [`STDOUT`](@ref) may now be read from the `rd` end of +Data written to [`stdout`](@ref) may now be read from the `rd` end of the pipe. The `wr` end is given for convenience in case the old -[`STDOUT`](@ref) object was cached by the user and needs to be replaced +[`stdout`](@ref) object was cached by the user and needs to be replaced elsewhere. !!! note @@ -1107,7 +1107,7 @@ redirect_stdout """ redirect_stderr([stream]) -> (rd, wr) -Like [`redirect_stdout`](@ref), but for [`STDERR`](@ref). +Like [`redirect_stdout`](@ref), but for [`stderr`](@ref). !!! note `stream` must be a `TTY`, a `Pipe`, or a [`TCPSocket`](@ref). @@ -1117,16 +1117,16 @@ redirect_stderr """ redirect_stdin([stream]) -> (rd, wr) -Like [`redirect_stdout`](@ref), but for [`STDIN`](@ref). +Like [`redirect_stdout`](@ref), but for [`stdin`](@ref). Note that the order of the return tuple is still `(rd, wr)`, -i.e. data to be read from [`STDIN`](@ref) may be written to `wr`. +i.e. data to be read from [`stdin`](@ref) may be written to `wr`. !!! note `stream` must be a `TTY`, a `Pipe`, or a [`TCPSocket`](@ref). """ redirect_stdin -for (F,S) in ((:redirect_stdin, :STDIN), (:redirect_stdout, :STDOUT), (:redirect_stderr, :STDERR)) +for (F,S) in ((:redirect_stdin, :stdin), (:redirect_stdout, :stdout), (:redirect_stderr, :stderr)) @eval function $F(f::Function, stream) STDOLD = $S local ret @@ -1143,8 +1143,8 @@ end """ redirect_stdout(f::Function, stream) -Run the function `f` while redirecting [`STDOUT`](@ref) to `stream`. -Upon completion, [`STDOUT`](@ref) is restored to its prior setting. +Run the function `f` while redirecting [`stdout`](@ref) to `stream`. +Upon completion, [`stdout`](@ref) is restored to its prior setting. !!! note `stream` must be a `TTY`, a `Pipe`, or a [`TCPSocket`](@ref). @@ -1154,8 +1154,8 @@ redirect_stdout(f::Function, stream) """ redirect_stderr(f::Function, stream) -Run the function `f` while redirecting [`STDERR`](@ref) to `stream`. -Upon completion, [`STDERR`](@ref) is restored to its prior setting. +Run the function `f` while redirecting [`stderr`](@ref) to `stream`. +Upon completion, [`stderr`](@ref) is restored to its prior setting. !!! note `stream` must be a `TTY`, a `Pipe`, or a [`TCPSocket`](@ref). @@ -1165,8 +1165,8 @@ redirect_stderr(f::Function, stream) """ redirect_stdin(f::Function, stream) -Run the function `f` while redirecting [`STDIN`](@ref) to `stream`. -Upon completion, [`STDIN`](@ref) is restored to its prior setting. +Run the function `f` while redirecting [`stdin`](@ref) to `stream`. +Upon completion, [`stdin`](@ref) is restored to its prior setting. !!! note `stream` must be a `TTY`, a `Pipe`, or a [`TCPSocket`](@ref). diff --git a/base/strings/io.jl b/base/strings/io.jl index 84af9cab211be..a2968fdaef19d 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -5,7 +5,7 @@ """ print([io::IO], xs...) -Write to `io` (or to the default output stream [`STDOUT`](@ref) +Write to `io` (or to the default output stream [`stdout`](@ref) if `io` is not given) a canonical (un-decorated) text representation of values `xs` if there is one, otherwise call [`show`](@ref). The representation used by `print` includes minimal formatting and tries to @@ -49,7 +49,7 @@ end println([io::IO], xs...) Print (using [`print`](@ref)) `xs` followed by a newline. -If `io` is not supplied, prints to [`STDOUT`](@ref). +If `io` is not supplied, prints to [`stdout`](@ref). # Examples ```jldoctest diff --git a/base/sysimg.jl b/base/sysimg.jl index e038f0f9e54e2..0e0bc038739c1 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -310,7 +310,7 @@ include("weakkeydict.jl") # Logging include("logging.jl") using .CoreLogging -global_logger(SimpleLogger(Core.STDERR, CoreLogging.Info)) +global_logger(SimpleLogger(Core.stderr, CoreLogging.Info)) # To limit dependency on rand functionality (implemented in the Random # module), Crand is used in file.jl, and could be used in error.jl @@ -470,8 +470,8 @@ function __init__() # Base library init reinit_stdio() Logging = root_module(PkgId(UUID(0x56ddb016_857b_54e1_b83d_db4d58db5568), "Logging")) - global_logger(Logging.ConsoleLogger(STDERR)) - Multimedia.reinit_displays() # since Multimedia.displays uses STDOUT as fallback + global_logger(Logging.ConsoleLogger(stderr)) + Multimedia.reinit_displays() # since Multimedia.displays uses stdout as fallback early_init() init_depot_path() init_load_path() diff --git a/base/sysinfo.jl b/base/sysinfo.jl index d6ca1c1aee38f..3fde68daa6b62 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -157,7 +157,7 @@ function _cpu_summary(io::IO, cpu::AbstractVector{CPUinfo}, i, j) println(io) end -function cpu_summary(io::IO=STDOUT, cpu::AbstractVector{CPUinfo} = cpu_info()) +function cpu_summary(io::IO=stdout, cpu::AbstractVector{CPUinfo} = cpu_info()) model = cpu[1].model first = 1 for i = 2:length(cpu) diff --git a/base/task.jl b/base/task.jl index 8f79632e80146..79da4c4e07959 100644 --- a/base/task.jl +++ b/base/task.jl @@ -238,7 +238,7 @@ function task_done_hook(t::Task) if !suppress_excp_printing(t) let bt = t.backtrace # run a new task to print the error for us - @schedule with_output_color(Base.error_color(), STDERR) do io + @schedule with_output_color(Base.error_color(), stderr) do io print(io, "ERROR (unhandled task failure): ") showerror(io, result, bt) println(io) diff --git a/base/util.jl b/base/util.jl index f458239990070..91ae262c1248f 100644 --- a/base/util.jl +++ b/base/util.jl @@ -346,7 +346,7 @@ If the keyword `bold` is given as `true`, the result will be printed in bold. printstyled(io::IO, msg...; bold::Bool=false, color::Union{Int,Symbol}=:normal) = with_output_color(print, color, io, msg...; bold=bold) printstyled(msg...; bold::Bool=false, color::Union{Int,Symbol}=:normal) = - printstyled(STDOUT, msg...; bold=bold, color=color) + printstyled(stdout, msg...; bold=bold, color=color) function julia_cmd(julia=joinpath(Sys.BINDIR, julia_exename())) opts = JLOptions() @@ -397,7 +397,7 @@ unsafe_securezero!(p::Ptr{Cvoid}, len::Integer=1) = Ptr{Cvoid}(unsafe_securezero if Sys.iswindows() function getpass(prompt::AbstractString) print(prompt) - flush(STDOUT) + flush(stdout) p = Vector{UInt8}(uninitialized, 128) # mimic Unix getpass in ignoring more than 128-char passwords # (also avoids any potential memory copies arising from push!) try diff --git a/base/version.jl b/base/version.jl index 7dc2fe27c3818..37ba3c2297c89 100644 --- a/base/version.jl +++ b/base/version.jl @@ -231,7 +231,7 @@ end const libllvm_version = VersionNumber(libllvm_version_string) -function banner(io::IO = STDOUT) +function banner(io::IO = stdout) if GIT_VERSION_INFO.tagged_commit commit_string = TAGGED_RELEASE_BANNER elseif isempty(GIT_VERSION_INFO.commit) diff --git a/contrib/build_sysimg.jl b/contrib/build_sysimg.jl index e57a5a27c8f0f..9ca9bdb133230 100644 --- a/contrib/build_sysimg.jl +++ b/contrib/build_sysimg.jl @@ -168,7 +168,7 @@ function link_sysimg(sysimg_path=nothing, cc=find_system_compiler(), debug=false info("$cc $(join(FLAGS, ' ')) -o $sysimg_file $sysimg_path.o") # Windows has difficulties overwriting a file in use so we first link to a temp file if Sys.iswindows() && isfile(sysimg_file) - if success(pipeline(`$cc $FLAGS -o $sysimg_path.tmp $sysimg_path.o`; stdout=STDOUT, stderr=STDERR)) + if success(pipeline(`$cc $FLAGS -o $sysimg_path.tmp $sysimg_path.o`; stdout=stdout, stderr=stderr)) mv(sysimg_file, "$sysimg_file.old"; force=true) mv("$sysimg_path.tmp", sysimg_file; force=true) end diff --git a/contrib/julia-config.jl b/contrib/julia-config.jl index 1ccdd3b2fa720..8ac742fade6c1 100755 --- a/contrib/julia-config.jl +++ b/contrib/julia-config.jl @@ -75,7 +75,7 @@ end function check_args(args) checked = intersect(args, options) if length(checked) == 0 || length(checked) != length(args) - println(STDERR, "Usage: julia-config [", join(options, " | "), "]") + println(stderr, "Usage: julia-config [", join(options, " | "), "]") exit(1) end end diff --git a/doc/src/base/constants.md b/doc/src/base/constants.md index 0f4c321d69067..b56659e77f302 100644 --- a/doc/src/base/constants.md +++ b/doc/src/base/constants.md @@ -17,9 +17,9 @@ Base.Sys.MACHINE See also: - * [`STDIN`](@ref) - * [`STDOUT`](@ref) - * [`STDERR`](@ref) + * [`stdin`](@ref) + * [`stdout`](@ref) + * [`stderr`](@ref) * [`ENV`](@ref) * [`ENDIAN_BOM`](@ref) * `Libc.MS_ASYNC` diff --git a/doc/src/base/io-network.md b/doc/src/base/io-network.md index ec69c67d3f4d8..c6b028127bedf 100644 --- a/doc/src/base/io-network.md +++ b/doc/src/base/io-network.md @@ -3,9 +3,9 @@ ## General I/O ```@docs -Base.STDOUT -Base.STDERR -Base.STDIN +Base.stdout +Base.stderr +Base.stdin Base.open Base.IOBuffer Base.take!(::Base.GenericIOBuffer) diff --git a/doc/src/devdocs/stdio.md b/doc/src/devdocs/stdio.md index 2adc259e03640..d17f7abc06bb9 100644 --- a/doc/src/devdocs/stdio.md +++ b/doc/src/devdocs/stdio.md @@ -29,24 +29,24 @@ void jl_safe_printf(const char *str, ...); ## Interface between JL_STD* and Julia code -[`Base.STDIN`](@ref), [`Base.STDOUT`](@ref) and [`Base.STDERR`](@ref) are bound to the `JL_STD*` libuv +[`Base.stdin`](@ref), [`Base.stdout`](@ref) and [`Base.stderr`](@ref) are bound to the `JL_STD*` libuv streams defined in the runtime. Julia's `__init__()` function (in `base/sysimg.jl`) calls `reinit_stdio()` (in `base/stream.jl`) -to create Julia objects for [`Base.STDIN`](@ref), [`Base.STDOUT`](@ref) and [`Base.STDERR`](@ref). +to create Julia objects for [`Base.stdin`](@ref), [`Base.stdout`](@ref) and [`Base.stderr`](@ref). `reinit_stdio()` uses [`ccall`](@ref) to retrieve pointers to `JL_STD*` and calls `jl_uv_handle_type()` to inspect the type of each stream. It then creates a Julia `Base.IOStream`, `Base.TTY` or `Base.PipeEndpoint` object to represent each stream, e.g.: ``` -$ julia -e 'println(typeof((STDIN, STDOUT, STDERR)))' +$ julia -e 'println(typeof((stdin, stdout, stderr)))' Tuple{Base.TTY,Base.TTY,Base.TTY} -$ julia -e 'println(typeof((STDIN, STDOUT, STDERR)))' < /dev/null 2>/dev/null +$ julia -e 'println(typeof((stdin, stdout, stderr)))' < /dev/null 2>/dev/null Tuple{IOStream,Base.TTY,IOStream} -$ echo hello | julia -e 'println(typeof((STDIN, STDOUT, STDERR)))' | cat +$ echo hello | julia -e 'println(typeof((stdin, stdout, stderr)))' | cat Tuple{Base.PipeEndpoint,Base.PipeEndpoint,Base.TTY} ``` diff --git a/doc/src/manual/faq.md b/doc/src/manual/faq.md index d367791dad20f..fe8ca94e66d2a 100644 --- a/doc/src/manual/faq.md +++ b/doc/src/manual/faq.md @@ -693,7 +693,7 @@ Consider the printed output from the following: ```jldoctest julia> @sync for i in 1:3 - @async write(STDOUT, string(i), " Foo ", " Bar ") + @async write(stdout, string(i), " Foo ", " Bar ") end 123 Foo Foo Foo Bar Bar Bar ``` @@ -706,7 +706,7 @@ in the above example results in: ```jldoctest julia> @sync for i in 1:3 - @async println(STDOUT, string(i), " Foo ", " Bar ") + @async println(stdout, string(i), " Foo ", " Bar ") end 1 Foo Bar 2 Foo Bar @@ -723,7 +723,7 @@ julia> @sync for i in 1:3 @async begin lock(l) try - write(STDOUT, string(i), " Foo ", " Bar ") + write(stdout, string(i), " Foo ", " Bar ") finally unlock(l) end diff --git a/doc/src/manual/modules.md b/doc/src/manual/modules.md index bb7c0f28e2b4f..28cc30e09ff6e 100644 --- a/doc/src/manual/modules.md +++ b/doc/src/manual/modules.md @@ -342,11 +342,11 @@ Other known potential failure scenarios include: of via its lookup path. For example, (in global scope): ```julia - #mystdout = Base.STDOUT #= will not work correctly, since this will copy Base.STDOUT into this module =# + #mystdout = Base.stdout #= will not work correctly, since this will copy Base.stdout into this module =# # instead use accessor functions: - getstdout() = Base.STDOUT #= best option =# + getstdout() = Base.stdout #= best option =# # or move the assignment into the runtime: - __init__() = global mystdout = Base.STDOUT #= also works =# + __init__() = global mystdout = Base.stdout #= also works =# ``` Several additional restrictions are placed on the operations that can be done while precompiling diff --git a/doc/src/manual/networking-and-streams.md b/doc/src/manual/networking-and-streams.md index d43c0d1cbc7c2..4d75c59729201 100644 --- a/doc/src/manual/networking-and-streams.md +++ b/doc/src/manual/networking-and-streams.md @@ -12,14 +12,14 @@ All Julia streams expose at least a [`read`](@ref) and a [`write`](@ref) method, stream as their first argument, e.g.: ```julia-repl -julia> write(STDOUT, "Hello World"); # suppress return value 11 with ; +julia> write(stdout, "Hello World"); # suppress return value 11 with ; Hello World -julia> read(STDIN, Char) +julia> read(stdin, Char) '\n': ASCII/Unicode U+000a (category Cc: Other, control) ``` -Note that [`write`](@ref) returns 11, the number of bytes (in `"Hello World"`) written to [`STDOUT`](@ref), +Note that [`write`](@ref) returns 11, the number of bytes (in `"Hello World"`) written to [`stdout`](@ref), but this return value is suppressed with the `;`. Here Enter was pressed again so that Julia would read the newline. Now, as you can see from this @@ -36,7 +36,7 @@ julia> x = zeros(UInt8, 4) 0x00 0x00 -julia> read!(STDIN, x) +julia> read!(stdin, x) abcd 4-element Array{UInt8,1}: 0x61 @@ -49,7 +49,7 @@ However, since this is slightly cumbersome, there are several convenience method example, we could have written the above as: ```julia-repl -julia> read(STDIN, 4) +julia> read(stdin, 4) abcd 4-element Array{UInt8,1}: 0x61 @@ -61,7 +61,7 @@ abcd or if we had wanted to read the entire line instead: ```julia-repl -julia> readline(STDIN) +julia> readline(stdin) abcd "abcd" ``` @@ -69,10 +69,10 @@ abcd Note that depending on your terminal settings, your TTY may be line buffered and might thus require an additional enter before the data is sent to Julia. -To read every line from [`STDIN`](@ref) you can use [`eachline`](@ref): +To read every line from [`stdin`](@ref) you can use [`eachline`](@ref): ```julia -for line in eachline(STDIN) +for line in eachline(stdin) print("Found $line") end ``` @@ -80,8 +80,8 @@ end or [`read`](@ref) if you wanted to read by character instead: ```julia -while !eof(STDIN) - x = read(STDIN, Char) +while !eof(stdin) + x = read(stdin, Char) println("Found: $x") end ``` @@ -92,18 +92,18 @@ Note that the [`write`](@ref) method mentioned above operates on binary streams. values do not get converted to any canonical text representation but are written out as is: ```jldoctest -julia> write(STDOUT, 0x61); # suppress return value 1 with ; +julia> write(stdout, 0x61); # suppress return value 1 with ; a ``` -Note that `a` is written to [`STDOUT`](@ref) by the [`write`](@ref) function and that the returned +Note that `a` is written to [`stdout`](@ref) by the [`write`](@ref) function and that the returned value is `1` (since `0x61` is one byte). For text I/O, use the [`print`](@ref) or [`show`](@ref) methods, depending on your needs (see the Julia Base reference for a detailed discussion of the difference between the two): ```jldoctest -julia> print(STDOUT, 0x61) +julia> print(stdout, 0x61) 97 ``` @@ -272,7 +272,7 @@ julia> clientside = connect(2001) TCPSocket(RawFD(28) open, 0 bytes waiting) julia> @async while true - write(STDOUT,readline(clientside)) + write(stdout,readline(clientside)) end Task (runnable) @0x00007fd31dc11870 diff --git a/doc/src/manual/parallel-computing.md b/doc/src/manual/parallel-computing.md index 195d039f152f2..cc7594ed9a1fd 100644 --- a/doc/src/manual/parallel-computing.md +++ b/doc/src/manual/parallel-computing.md @@ -1071,8 +1071,8 @@ manner: * [`addprocs`](@ref) is called on the master process with a `ClusterManager` object. * [`addprocs`](@ref) calls the appropriate [`launch`](@ref) method which spawns required number of worker processes on appropriate machines. - * Each worker starts listening on a free port and writes out its host and port information to [`STDOUT`](@ref). - * The cluster manager captures the [`STDOUT`](@ref) of each worker and makes it available to the + * Each worker starts listening on a free port and writes out its host and port information to [`stdout`](@ref). + * The cluster manager captures the [`stdout`](@ref) of each worker and makes it available to the master process. * The master process parses this information and sets up TCP/IP connections to each worker. * Every worker is also notified of other workers in the cluster. @@ -1315,7 +1315,7 @@ on the master process: are allowed to connect to each other. * The cookie may be passed to the workers at startup via argument `--worker=`. If argument `--worker` is specified without the cookie, the worker tries to read the cookie from its - standard input ([`STDIN`](@ref)). The `STDIN` is closed immediately after the cookie is retrieved. + standard input ([`stdin`](@ref)). The `stdin` is closed immediately after the cookie is retrieved. * `ClusterManager`s can retrieve the cookie on the master by calling [`cluster_cookie()`](@ref). Cluster managers not using the default TCP/IP transport (and hence not specifying `--worker`) must call `init_worker(cookie, manager)` with the same cookie as on the master. diff --git a/doc/src/manual/profile.md b/doc/src/manual/profile.md index 29cda5c48782f..00d91cf5f0d7c 100644 --- a/doc/src/manual/profile.md +++ b/doc/src/manual/profile.md @@ -210,12 +210,12 @@ be very useful, but sometimes you want to start fresh; you can do so with [`Prof [`Profile.print`](@ref) has more options than we've described so far. Let's see the full declaration: ```julia -function print(io::IO = STDOUT, data = fetch(); kwargs...) +function print(io::IO = stdout, data = fetch(); kwargs...) ``` Let's first discuss the two positional arguments, and later the keyword arguments: - * `io` -- Allows you to save the results to a buffer, e.g. a file, but the default is to print to `STDOUT` + * `io` -- Allows you to save the results to a buffer, e.g. a file, but the default is to print to `stdout` (the console). * `data` -- Contains the data you want to analyze; by default that is obtained from [`Profile.fetch()`](@ref), which pulls out the backtraces from a pre-allocated buffer. For example, if you want to profile @@ -224,7 +224,7 @@ Let's first discuss the two positional arguments, and later the keyword argument ```julia data = copy(Profile.fetch()) Profile.clear() - @profile Profile.print(STDOUT, data) # Prints the previous results + @profile Profile.print(stdout, data) # Prints the previous results Profile.print() # Prints results from Profile.print() ``` diff --git a/doc/src/manual/running-external-programs.md b/doc/src/manual/running-external-programs.md index 065b4020d2802..88fc04405e43c 100644 --- a/doc/src/manual/running-external-programs.md +++ b/doc/src/manual/running-external-programs.md @@ -14,7 +14,7 @@ differs in several aspects from the behavior in various shells, Perl, or Ruby: You can use this object to connect the command to others via pipes, [`run`](@ref) it, and [`read`](@ref) or [`write`](@ref) to it. * When the command is run, Julia does not capture its output unless you specifically arrange for - it to. Instead, the output of the command by default goes to [`STDOUT`](@ref) as it would using + it to. Instead, the output of the command by default goes to [`stdout`](@ref) as it would using `libc`'s `system` call. * The command is never run with a shell. Instead, Julia parses the command syntax directly, appropriately interpolating variables and splitting on words as the shell would, respecting shell quoting syntax. @@ -33,7 +33,7 @@ julia> run(mycommand) hello ``` -The `hello` is the output of the `echo` command, sent to [`STDOUT`](@ref). The run method itself +The `hello` is the output of the `echo` command, sent to [`stdout`](@ref). The run method itself returns `nothing`, and throws an [`ErrorException`](@ref) if the external command fails to run successfully. @@ -50,7 +50,7 @@ true More generally, you can use [`open`](@ref) to read from or write to an external command. ```jldoctest -julia> open(`less`, "w", STDOUT) do io +julia> open(`less`, "w", stdout) do io for i = 1:3 println(io, i) end @@ -280,7 +280,7 @@ hello ``` The order of the output here is non-deterministic because the two `echo` processes are started -nearly simultaneously, and race to make the first write to the [`STDOUT`](@ref) descriptor they +nearly simultaneously, and race to make the first write to the [`stdout`](@ref) descriptor they share with each other and the `julia` parent process. Julia lets you pipe the output from both of these processes to another program: @@ -347,7 +347,7 @@ generates lines with the numbers 0 through 9 on them, while two parallel process output, one prefixing lines with the letter "A", the other with the letter "B". Which consumer gets the first line is non-deterministic, but once that race has been won, the lines are consumed alternately by one process and then the other. (Setting `$|=1` in Perl causes each print statement -to flush the [`STDOUT`](@ref) handle, which is necessary for this example to work. Otherwise all +to flush the [`stdout`](@ref) handle, which is necessary for this example to work. Otherwise all the output is buffered and printed to the pipe at once, to be read by just one consumer process.) Here is an even more complex multi-stage producer-consumer example: diff --git a/doc/src/manual/types.md b/doc/src/manual/types.md index e30405b255998..c64215b7a9203 100644 --- a/doc/src/manual/types.md +++ b/doc/src/manual/types.md @@ -1251,8 +1251,8 @@ julia> [Polar(3, 4.0), Polar(4.0,5.3)] ``` where the single-line `show(io, z)` form is still used for an array of `Polar` values. Technically, -the REPL calls `display(z)` to display the result of executing a line, which defaults to `show(STDOUT, MIME("text/plain"), z)`, -which in turn defaults to `show(STDOUT, z)`, but you should *not* define new [`display`](@ref) +the REPL calls `display(z)` to display the result of executing a line, which defaults to `show(stdout, MIME("text/plain"), z)`, +which in turn defaults to `show(stdout, z)`, but you should *not* define new [`display`](@ref) methods unless you are defining a new multimedia display handler (see [Multimedia I/O](@ref)). Moreover, you can also define `show` methods for other MIME types in order to enable richer display @@ -1269,7 +1269,7 @@ A `Polar` object will then display automatically using HTML in an environment th display, but you can call `show` manually to get HTML output if you want: ```jldoctest polartype -julia> show(STDOUT, "text/html", Polar(3.0,4.0)) +julia> show(stdout, "text/html", Polar(3.0,4.0)) Polar{Float64} complex number: 3.0 e4.0 i ``` diff --git a/examples/clustermanager/0mq/ZMQCM.jl b/examples/clustermanager/0mq/ZMQCM.jl index 1a049161fec35..01d98d853aa7d 100644 --- a/examples/clustermanager/0mq/ZMQCM.jl +++ b/examples/clustermanager/0mq/ZMQCM.jl @@ -112,7 +112,7 @@ function setup_connection(zid, initiated_by) end (read_stream, write_stream) catch e - Base.show_backtrace(STDOUT,catch_backtrace()) + Base.show_backtrace(stdout,catch_backtrace()) println(e) rethrow(e) end @@ -168,7 +168,7 @@ function recv_data() (from_zid, data) catch e - Base.show_backtrace(STDOUT,catch_backtrace()) + Base.show_backtrace(stdout,catch_backtrace()) println(e) rethrow(e) end @@ -189,7 +189,7 @@ function start_master(np) unsafe_write(r_s, pointer(data), length(data)) end catch e - Base.show_backtrace(STDOUT,catch_backtrace()) + Base.show_backtrace(stdout,catch_backtrace()) println(e) rethrow(e) end diff --git a/examples/embedding/embedding-test.jl b/examples/embedding/embedding-test.jl index 261e77a9d2902..4303162b5e278 100644 --- a/examples/embedding/embedding-test.jl +++ b/examples/embedding/embedding-test.jl @@ -12,7 +12,7 @@ end @testset "embedding example" begin out = Pipe() err = Pipe() - p = spawn(pipeline(Cmd(ARGS), in=devnull, stdout=out, stderr=err)) + p = spawn(pipeline(Cmd(ARGS), stdin=devnull, stdout=out, stderr=err)) close(out.in) close(err.in) out_task = @async readlines(out) diff --git a/src/rtutils.c b/src/rtutils.c index 4bd3142cd9f85..b67ca628e0c53 100644 --- a/src/rtutils.c +++ b/src/rtutils.c @@ -471,14 +471,14 @@ JL_DLLEXPORT void jl_flush_cstdio(void) JL_DLLEXPORT jl_value_t *jl_stdout_obj(void) { if (jl_base_module == NULL) return NULL; - jl_value_t *stdout_obj = jl_get_global(jl_base_module, jl_symbol("STDOUT")); + jl_value_t *stdout_obj = jl_get_global(jl_base_module, jl_symbol("stdout")); return stdout_obj; } JL_DLLEXPORT jl_value_t *jl_stderr_obj(void) { if (jl_base_module == NULL) return NULL; - jl_value_t *stderr_obj = jl_get_global(jl_base_module, jl_symbol("STDERR")); + jl_value_t *stderr_obj = jl_get_global(jl_base_module, jl_symbol("stderr")); return stderr_obj; } diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index 65bed61acfda8..1b0704b2a7ecc 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -173,24 +173,24 @@ worker_timeout() = parse(Float64, get(ENV, "JULIA_WORKER_TIMEOUT", "60.0")) ## worker creation and setup ## """ - start_worker([out::IO=STDOUT], cookie::AbstractString=readline(STDIN)) + start_worker([out::IO=stdout], cookie::AbstractString=readline(stdin)) `start_worker` is an internal function which is the default entry point for worker processes connecting via TCP/IP. It sets up the process as a Julia cluster worker. -host:port information is written to stream `out` (defaults to STDOUT). +host:port information is written to stream `out` (defaults to stdout). -The function closes STDIN (after reading the cookie if required), redirects STDERR to STDOUT, +The function closes stdin (after reading the cookie if required), redirects stderr to stdout, listens on a free port (or if specified, the port in the `--bind-to` command line option) and schedules tasks to process incoming TCP connections and requests. It does not return. """ -start_worker(cookie::AbstractString=readline(STDIN)) = start_worker(STDOUT, cookie) -function start_worker(out::IO, cookie::AbstractString=readline(STDIN)) - close(STDIN) # workers will not use it - redirect_stderr(STDOUT) +start_worker(cookie::AbstractString=readline(stdin)) = start_worker(stdout, cookie) +function start_worker(out::IO, cookie::AbstractString=readline(stdin)) + close(stdin) # workers will not use it + redirect_stderr(stdout) init_worker(cookie) interface = IPv4(LPROC.bind_addr) @@ -223,7 +223,7 @@ function start_worker(out::IO, cookie::AbstractString=readline(STDIN)) check_master_connect() while true; wait(); end catch err - print(STDERR, "unhandled exception on $(myid()): $(err)\nexiting.\n") + print(stderr, "unhandled exception on $(myid()): $(err)\nexiting.\n") end close(sock) @@ -235,8 +235,8 @@ function redirect_worker_output(ident, stream) @schedule while !eof(stream) line = readline(stream) if startswith(line, " From worker ") - # STDOUT's of "additional" workers started from an initial worker on a host are not available - # on the master directly - they are routed via the initial worker's STDOUT. + # stdout's of "additional" workers started from an initial worker on a host are not available + # on the master directly - they are routed via the initial worker's stdout. println(line) else println(" From worker $(ident):\t$line") @@ -629,7 +629,7 @@ function check_master_connect() end if !haskey(map_pid_wrkr, 1) - print(STDERR, "Master process (id 1) could not connect within $timeout seconds.\nexiting.\n") + print(stderr, "Master process (id 1) could not connect within $timeout seconds.\nexiting.\n") exit(1) end end diff --git a/stdlib/Distributed/src/managers.jl b/stdlib/Distributed/src/managers.jl index 97669bd455308..fed78461edc34 100644 --- a/stdlib/Distributed/src/managers.jl +++ b/stdlib/Distributed/src/managers.jl @@ -129,7 +129,7 @@ function launch(manager::SSHManager, params::Dict, launched::Array, launch_ntfy: launch_tasks[i] = @schedule try launch_on_machine(manager, machine, cnt, params, launched, launch_ntfy) catch e - print(STDERR, "exception launching on machine $(machine) : $(e)\n") + print(stderr, "exception launching on machine $(machine) : $(e)\n") end end end diff --git a/stdlib/Distributed/src/messages.jl b/stdlib/Distributed/src/messages.jl index c44ea38a660ef..8f9e13ef06a2f 100644 --- a/stdlib/Distributed/src/messages.jl +++ b/stdlib/Distributed/src/messages.jl @@ -201,7 +201,7 @@ function flush_gc_msgs() end catch e bt = catch_backtrace() - @schedule showerror(STDERR, e, bt) + @schedule showerror(stderr, e, bt) end end diff --git a/stdlib/Distributed/src/process_messages.jl b/stdlib/Distributed/src/process_messages.jl index 6b5efdb1c6617..079646d89ff8d 100644 --- a/stdlib/Distributed/src/process_messages.jl +++ b/stdlib/Distributed/src/process_messages.jl @@ -57,7 +57,7 @@ function run_work_thunk(thunk, print_error) catch err ce = CapturedException(err, catch_backtrace()) result = RemoteException(ce) - print_error && showerror(STDERR, ce) + print_error && showerror(stderr, ce) end return result end @@ -200,8 +200,8 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool) end if wpid < 1 - println(STDERR, e, CapturedException(e, catch_backtrace())) - println(STDERR, "Process($(myid())) - Unknown remote, closing connection.") + println(stderr, e, CapturedException(e, catch_backtrace())) + println(stderr, "Process($(myid())) - Unknown remote, closing connection.") elseif !(wpid in map_del_wrkr) werr = worker_from_id(wpid) oldstate = werr.state @@ -226,7 +226,7 @@ function message_handler_loop(r_stream::IO, w_stream::IO, incoming::Bool) if (myid() == 1) && (wpid > 1) if oldstate != W_TERMINATING - println(STDERR, "Worker $wpid terminated.") + println(stderr, "Worker $wpid terminated.") rethrow(e) end end diff --git a/stdlib/Distributed/src/remotecall.jl b/stdlib/Distributed/src/remotecall.jl index 940bf7c7cef30..b4d287bc032f4 100644 --- a/stdlib/Distributed/src/remotecall.jl +++ b/stdlib/Distributed/src/remotecall.jl @@ -445,7 +445,7 @@ invoked, the order of executions on the remote worker is undetermined. For examp to `f1`, followed by `f2` and `f3` in that order. However, it is not guaranteed that `f1` is executed before `f3` on worker 2. -Any exceptions thrown by `f` are printed to [`STDERR`](@ref) on the remote worker. +Any exceptions thrown by `f` are printed to [`stderr`](@ref) on the remote worker. Keyword arguments, if any, are passed through to `f`. """ diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index 098e226c1c948..e49341961a91d 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -1036,8 +1036,8 @@ end # Test the following addprocs error conditions # - invalid host name - github issue #20372 # - julia exe exiting with an error -# - timeout reading host:port from worker STDOUT -# - host:port not found in worker STDOUT in the first 1000 lines +# - timeout reading host:port from worker stdout +# - host:port not found in worker stdout in the first 1000 lines struct ErrorSimulator <: ClusterManager mode @@ -1079,7 +1079,7 @@ append!(testruns, [ ]) for (addp_testf, expected_errstr, env) in testruns - old_stdout = STDOUT + old_stdout = stdout stdout_out, stdout_in = redirect_stdout() stdout_txt = @schedule filter!(readlines(stdout_out)) do s return !startswith(s, "\tFrom failed worker startup:\t") diff --git a/stdlib/Distributed/test/runtests.jl b/stdlib/Distributed/test/runtests.jl index 1683944a42a25..4ab1b69739840 100644 --- a/stdlib/Distributed/test/runtests.jl +++ b/stdlib/Distributed/test/runtests.jl @@ -7,6 +7,6 @@ disttestfile = joinpath(@__DIR__, "distributed_exec.jl") cmd = `$test_exename $test_exeflags $disttestfile` -if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) && ccall(:jl_running_on_valgrind,Cint,()) == 0 +if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) && ccall(:jl_running_on_valgrind,Cint,()) == 0 error("Distributed test failed, cmd : $cmd") end diff --git a/stdlib/InteractiveUtils/src/InteractiveUtils.jl b/stdlib/InteractiveUtils/src/InteractiveUtils.jl index f2327d5fd990a..c507dbc412d2a 100644 --- a/stdlib/InteractiveUtils/src/InteractiveUtils.jl +++ b/stdlib/InteractiveUtils/src/InteractiveUtils.jl @@ -45,7 +45,7 @@ end varinfo(pat::Regex) = varinfo(Main, pat) """ - versioninfo(io::IO=STDOUT; verbose::Bool=false, packages::Bool=false) + versioninfo(io::IO=stdout; verbose::Bool=false, packages::Bool=false) Print information about the version of Julia in use. The output is controlled with boolean keyword arguments: @@ -53,7 +53,7 @@ controlled with boolean keyword arguments: - `packages`: print information about installed packages - `verbose`: print all additional information """ -function versioninfo(io::IO=STDOUT; verbose::Bool=false, packages::Bool=false) +function versioninfo(io::IO=stdout; verbose::Bool=false, packages::Bool=false) println(io, "Julia Version $VERSION") if !isempty(Base.GIT_VERSION_INFO.commit_short) println(io, "Commit $(Base.GIT_VERSION_INFO.commit_short) ($(Base.GIT_VERSION_INFO.date_string))") diff --git a/stdlib/InteractiveUtils/src/codeview.jl b/stdlib/InteractiveUtils/src/codeview.jl index 2b42d010161e7..1c7555fc4f350 100644 --- a/stdlib/InteractiveUtils/src/codeview.jl +++ b/stdlib/InteractiveUtils/src/codeview.jl @@ -6,7 +6,7 @@ code_warntype([io::IO], f, types) Prints lowered and type-inferred ASTs for the methods matching the given generic function -and type signature to `io` which defaults to `STDOUT`. The ASTs are annotated in such a way +and type signature to `io` which defaults to `stdout`. The ASTs are annotated in such a way as to cause "non-leaf" types to be emphasized (if color is available, displayed in red). This serves as a warning of potential type instability. Not all non-leaf types are particularly problematic for performance, so the results need to be used judiciously. @@ -58,7 +58,7 @@ function code_warntype(io::IO, f, @nospecialize(t)) end nothing end -code_warntype(f, @nospecialize(t)) = code_warntype(STDOUT, f, t) +code_warntype(f, @nospecialize(t)) = code_warntype(stdout, f, t) import Base.CodegenParams @@ -111,7 +111,7 @@ function _dump_function_linfo(linfo::Core.MethodInstance, world::UInt, native::B end """ - code_llvm([io=STDOUT,], f, types) + code_llvm([io=stdout,], f, types) Prints the LLVM bitcodes generated for running the method matching the given generic function and type signature to `io`. @@ -120,11 +120,11 @@ All metadata and dbg.* calls are removed from the printed bitcode. Use code_llvm """ code_llvm(io::IO, @nospecialize(f), @nospecialize(types=Tuple), strip_ir_metadata=true, dump_module=false) = print(io, _dump_function(f, types, false, false, strip_ir_metadata, dump_module)) -code_llvm(@nospecialize(f), @nospecialize(types=Tuple)) = code_llvm(STDOUT, f, types) -code_llvm_raw(@nospecialize(f), @nospecialize(types=Tuple)) = code_llvm(STDOUT, f, types, false) +code_llvm(@nospecialize(f), @nospecialize(types=Tuple)) = code_llvm(stdout, f, types) +code_llvm_raw(@nospecialize(f), @nospecialize(types=Tuple)) = code_llvm(stdout, f, types, false) """ - code_native([io=STDOUT,], f, types; syntax = :att) + code_native([io=stdout,], f, types; syntax = :att) Prints the native assembly instructions generated for running the method matching the given generic function and type signature to `io`. @@ -132,5 +132,5 @@ Switch assembly syntax using `syntax` symbol parameter set to `:att` for AT&T sy """ code_native(io::IO, @nospecialize(f), @nospecialize(types=Tuple); syntax::Symbol = :att) = print(io, _dump_function(f, types, true, false, false, false, syntax)) -code_native(@nospecialize(f), @nospecialize(types=Tuple); syntax::Symbol = :att) = code_native(STDOUT, f, types, syntax = syntax) +code_native(@nospecialize(f), @nospecialize(types=Tuple); syntax::Symbol = :att) = code_native(stdout, f, types, syntax = syntax) code_native(::IO, ::Any, ::Symbol) = error("illegal code_native call") # resolve ambiguous call diff --git a/stdlib/InteractiveUtils/src/editless.jl b/stdlib/InteractiveUtils/src/editless.jl index 614393655c5c0..fd920b413fa58 100644 --- a/stdlib/InteractiveUtils/src/editless.jl +++ b/stdlib/InteractiveUtils/src/editless.jl @@ -73,7 +73,7 @@ function edit(path::AbstractString, line::Integer=0) (Ptr{Cvoid}, Cwstring, Cwstring, Ptr{Cvoid}, Ptr{Cvoid}, Cint), C_NULL, "open", path, C_NULL, C_NULL, 10) ≤ 32) elseif background - spawn(pipeline(cmd, stderr=STDERR)) + spawn(pipeline(cmd, stderr=stderr)) else run(cmd) end diff --git a/stdlib/InteractiveUtils/test/runtests.jl b/stdlib/InteractiveUtils/test/runtests.jl index d13cb94d37013..d10ecc4a092a6 100644 --- a/stdlib/InteractiveUtils/test/runtests.jl +++ b/stdlib/InteractiveUtils/test/runtests.jl @@ -134,7 +134,7 @@ end # Issue #16326 mktemp() do f, io - OLDSTDOUT = STDOUT + OLDSTDOUT = stdout redirect_stdout(io) @test try @code_native map(abs, rand(3)); true; catch; false; end redirect_stdout(OLDSTDOUT) diff --git a/stdlib/LibGit2/test/libgit2.jl b/stdlib/LibGit2/test/libgit2.jl index 103e6b345ed82..62b34cdc9bc41 100644 --- a/stdlib/LibGit2/test/libgit2.jl +++ b/stdlib/LibGit2/test/libgit2.jl @@ -1802,7 +1802,7 @@ mktempdir() do dir @test LibGit2.credential_helpers(cfg, GitCredential("https", "github.com")) == expected - println(STDERR, "The following 'Resetting the helper list...' warning is expected:") + println(stderr, "The following 'Resetting the helper list...' warning is expected:") @test_broken LibGit2.credential_helpers(cfg, GitCredential("https", "mygithost")) == expected[2] end end diff --git a/stdlib/LinearAlgebra/src/LinearAlgebra.jl b/stdlib/LinearAlgebra/src/LinearAlgebra.jl index ece3db422714a..a7900f9c1a46b 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -335,7 +335,7 @@ const × = cross export ⋅, × -function versioninfo(io::IO=STDOUT) +function versioninfo(io::IO=stdout) if Base.libblas_name == "libopenblas" || BLAS.vendor() == :openblas || BLAS.vendor() == :openblas64 openblas_config = BLAS.openblas_get_config() println(io, "BLAS: libopenblas (", openblas_config, ")") diff --git a/stdlib/Logging/src/ConsoleLogger.jl b/stdlib/Logging/src/ConsoleLogger.jl index 5030852bffbca..4d518bf13e61c 100644 --- a/stdlib/Logging/src/ConsoleLogger.jl +++ b/stdlib/Logging/src/ConsoleLogger.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license """ - ConsoleLogger(stream=STDERR, min_level=Info; meta_formatter=default_metafmt, + ConsoleLogger(stream=stderr, min_level=Info; meta_formatter=default_metafmt, show_limited=true, right_justify=0) Logger with formatting optimized for readability in a text console, for example @@ -30,7 +30,7 @@ struct ConsoleLogger <: AbstractLogger right_justify::Int message_limits::Dict{Any,Int} end -function ConsoleLogger(stream::IO=STDERR, min_level=Info; +function ConsoleLogger(stream::IO=stderr, min_level=Info; meta_formatter=default_metafmt, show_limited=true, right_justify=0) ConsoleLogger(stream, min_level, meta_formatter, diff --git a/stdlib/Pkg/src/Pkg.jl b/stdlib/Pkg/src/Pkg.jl index 88cd02050ba98..753b72151312f 100644 --- a/stdlib/Pkg/src/Pkg.jl +++ b/stdlib/Pkg/src/Pkg.jl @@ -152,14 +152,14 @@ installed(pkg::AbstractString) = cd(Entry.installed,splitjl(pkg)) Prints out a summary of what packages are installed and what version and state they're in. """ -status(io::IO=STDOUT) = cd(Entry.status,io) +status(io::IO=stdout) = cd(Entry.status,io) """ status(pkg) Prints out a summary of what version and state `pkg`, specifically, is in. """ -status(pkg::AbstractString, io::IO=STDOUT) = cd(Entry.status,io,splitjl(pkg)) +status(pkg::AbstractString, io::IO=stdout) = cd(Entry.status,io,splitjl(pkg)) """ clone(pkg) diff --git a/stdlib/Pkg/src/entry.jl b/stdlib/Pkg/src/entry.jl index 21a9cbd982fb9..4837d905ff2ac 100644 --- a/stdlib/Pkg/src/entry.jl +++ b/stdlib/Pkg/src/entry.jl @@ -618,7 +618,7 @@ function build(pkg::AbstractString, build_file::AbstractString, errfile::Abstrac --eval $code ``` - success(pipeline(cmd, stdout=STDOUT, stderr=STDERR)) + success(pipeline(cmd, stdout=stdout, stderr=stderr)) end function build!(pkgs::Vector, seen::Set, errfile::AbstractString) @@ -685,7 +685,7 @@ function updatehook(pkgs::Vector) errs = Dict() updatehook!(pkgs,errs) isempty(errs) && return - println(STDERR) + println(stderr) @warn """ ------------------------------------------------------------ # Update hook summary diff --git a/stdlib/Pkg/test/pkg.jl b/stdlib/Pkg/test/pkg.jl index fb37268ec549f..01d91d7b69cab 100644 --- a/stdlib/Pkg/test/pkg.jl +++ b/stdlib/Pkg/test/pkg.jl @@ -414,13 +414,13 @@ temp_pkg_dir() do touch(depsbuild) # Pkg.build works without the src directory now # but it's probably fine to require it. - msg = read(`$(Base.julia_cmd()) --startup-file=no -e 'redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.build("BuildFail")'`, String) + msg = read(`$(Base.julia_cmd()) --startup-file=no -e 'redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.build("BuildFail")'`, String) @test contains(msg, "Building BuildFail") @test !contains(msg, "Build failed for BuildFail") open(depsbuild, "w") do fd println(fd, "error(\"Throw build error\")") end - msg = read(`$(Base.julia_cmd()) --startup-file=no -e 'redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.build("BuildFail")'`, String) + msg = read(`$(Base.julia_cmd()) --startup-file=no -e 'redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.build("BuildFail")'`, String) @test contains(msg, "Building BuildFail") @test contains(msg, "Build failed for BuildFail") @test contains(msg, "Pkg.build(\"BuildFail\")") @@ -431,7 +431,7 @@ temp_pkg_dir() do let package = "Example" Pkg.rm(package) # Remove package if installed @test Pkg.installed(package) === nothing # Registered with METADATA but not installed - msg = read(ignorestatus(`$(Base.julia_cmd()) --startup-file=no -e "redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.build(\"$package\")"`), String) + msg = read(ignorestatus(`$(Base.julia_cmd()) --startup-file=no -e "redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.build(\"$package\")"`), String) @test contains(msg, "$package is not an installed package") @test !contains(msg, "signal (15)") end @@ -546,7 +546,7 @@ temp_pkg_dir() do Pkg.add(package) msg = read(ignorestatus(`$(Base.julia_cmd()) --startup-file=no -e - "redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); using Example; import Pkg; Pkg.update(\"$package\")"`), String) + "redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); using Example; import Pkg; Pkg.update(\"$package\")"`), String) @test contains(msg, Regex("- $package.*Restart Julia to use the updated versions","s")) end @@ -569,7 +569,7 @@ temp_pkg_dir() do write(joinpath(home, ".juliarc.jl"), "const JULIA_RC_LOADED = true") withenv((Sys.iswindows() ? "USERPROFILE" : "HOME") => home) do - code = "redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.build(\"$package\")" + code = "redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.build(\"$package\")" msg = read(`$(Base.julia_cmd()) --startup-file=no -e $code`, String) @test contains(msg, "JULIA_RC_LOADED defined false") @test contains(msg, "Main.JULIA_RC_LOADED defined false") @@ -578,7 +578,7 @@ temp_pkg_dir() do @test contains(msg, "JULIA_RC_LOADED defined false") @test contains(msg, "Main.JULIA_RC_LOADED defined true") - code = "redirect_stderr(STDOUT); using Logging; global_logger(SimpleLogger(STDOUT)); import Pkg; Pkg.test(\"$package\")" + code = "redirect_stderr(stdout); using Logging; global_logger(SimpleLogger(stdout)); import Pkg; Pkg.test(\"$package\")" msg = read(`$(Base.julia_cmd()) --startup-file=no -e $code`, String) @test contains(msg, "JULIA_RC_LOADED defined false") @@ -596,8 +596,8 @@ temp_pkg_dir() do stdout_file = Pkg.dir(package, "stdout.txt") stderr_file = Pkg.dir(package, "stderr.txt") content = """ - println(STDOUT, "stdout") - println(STDERR, "stderr") + println(stdout, "stdout") + println(stderr, "stderr") """ write_build(package, content) diff --git a/stdlib/Printf/src/Printf.jl b/stdlib/Printf/src/Printf.jl index 6abf46719b8b4..44d192e1c4739 100644 --- a/stdlib/Printf/src/Printf.jl +++ b/stdlib/Printf/src/Printf.jl @@ -36,7 +36,7 @@ julia> @printf "%.0f %.1f %f\\n" 0.5 0.025 -0.0078125 macro printf(args...) isempty(args) && throw(ArgumentError("@printf: called with no arguments")) if isa(args[1], AbstractString) || is_str_expr(args[1]) - _printf("@printf", :STDOUT, args[1], args[2:end]) + _printf("@printf", :stdout, args[1], args[2:end]) else (length(args) >= 2 && (isa(args[2], AbstractString) || is_str_expr(args[2]))) || throw(ArgumentError("@printf: first or second argument must be a format string")) diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index b931f89d59bd3..58287d4e4caa9 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -101,9 +101,9 @@ struct ProfileFormat end """ - print([io::IO = STDOUT,] [data::Vector]; kwargs...) + print([io::IO = stdout,] [data::Vector]; kwargs...) -Prints profiling results to `io` (by default, `STDOUT`). If you do not +Prints profiling results to `io` (by default, `stdout`). If you do not supply a `data` vector, the internal buffer of accumulated backtraces will be used. @@ -156,7 +156,7 @@ function print(io::IO, data::Vector{<:Unsigned}, lidict::LineInfoDict, fmt::Prof end """ - print([io::IO = STDOUT,] data::Vector, lidict::LineInfoDict; kwargs...) + print([io::IO = stdout,] data::Vector, lidict::LineInfoDict; kwargs...) Prints profiling results to `io`. This variant is used to examine results exported by a previous call to [`retrieve`](@ref). Supply the vector `data` of backtraces and @@ -165,7 +165,7 @@ a dictionary `lidict` of line information. See `Profile.print([io], data)` for an explanation of the valid keyword arguments. """ print(data::Vector{<:Unsigned} = fetch(), lidict::LineInfoDict = getdict(data); kwargs...) = - print(STDOUT, data, lidict; kwargs...) + print(stdout, data, lidict; kwargs...) """ retrieve() -> data, lidict diff --git a/stdlib/REPL/src/TerminalMenus/TerminalMenus.jl b/stdlib/REPL/src/TerminalMenus/TerminalMenus.jl index d25a8acb5d2d8..35783ed63e12c 100644 --- a/stdlib/REPL/src/TerminalMenus/TerminalMenus.jl +++ b/stdlib/REPL/src/TerminalMenus/TerminalMenus.jl @@ -6,7 +6,7 @@ import REPL function __init__() global terminal - terminal = REPL.Terminals.TTYTerminal(get(ENV, "TERM", Sys.iswindows() ? "" : "dumb"), STDIN, STDOUT, STDERR) + terminal = REPL.Terminals.TTYTerminal(get(ENV, "TERM", Sys.iswindows() ? "" : "dumb"), stdin, stdout, stderr) end include("util.jl") diff --git a/stdlib/REPL/src/TerminalMenus/util.jl b/stdlib/REPL/src/TerminalMenus/util.jl index e6cc18706dbe3..1611e5175bb8e 100644 --- a/stdlib/REPL/src/TerminalMenus/util.jl +++ b/stdlib/REPL/src/TerminalMenus/util.jl @@ -33,14 +33,14 @@ function disableRawMode(term) end -# Reads a single byte from STDIN -readNextChar(stream::IO=STDIN) = Char(read(stream,1)[1]) +# Reads a single byte from stdin +readNextChar(stream::IO=stdin) = Char(read(stream,1)[1]) -# Read the next key from STDIN. It is also able to read several bytes for +# Read the next key from stdin. It is also able to read several bytes for # escaped keys such as the arrow keys, home/end keys, etc. # Escaped keys are returned using the `Key` enum. -readKey(stream::IO=STDIN) = UInt32(_readKey(stream)) -function _readKey(stream::IO=STDIN) +readKey(stream::IO=stdin) = UInt32(_readKey(stream)) +function _readKey(stream::IO=stdin) c = readNextChar(stream) # Escape characters diff --git a/stdlib/REPL/src/docview.jl b/stdlib/REPL/src/docview.jl index 6b9adb1ae20b0..22edebcd79592 100644 --- a/stdlib/REPL/src/docview.jl +++ b/stdlib/REPL/src/docview.jl @@ -17,7 +17,7 @@ using InteractiveUtils: subtypes # This is split into helpmode and _helpmode to easier unittest _helpmode helpmode(io::IO, line::AbstractString) = :($REPL.insert_hlines($io, $(REPL._helpmode(io, line)))) -helpmode(line::AbstractString) = helpmode(STDOUT, line) +helpmode(line::AbstractString) = helpmode(stdout, line) function _helpmode(io::IO, line::AbstractString) line = strip(line) @@ -39,7 +39,7 @@ function _helpmode(io::IO, line::AbstractString) # so that the resulting expressions are evaluated in the Base.Docs namespace :($REPL.@repl $io $expr) end -_helpmode(line::AbstractString) = _helpmode(STDOUT, line) +_helpmode(line::AbstractString) = _helpmode(stdout, line) # Print vertical lines along each docstring if there are multiple docs function insert_hlines(io::IO, docs) @@ -224,14 +224,14 @@ function repl_search(io::IO, s) printmatches(io, s, doc_completions(s), cols = displaysize(io)[2] - length(pre)) println(io, "\n") end -repl_search(s) = repl_search(STDOUT, s) +repl_search(s) = repl_search(stdout, s) function repl_corrections(io::IO, s) print(io, "Couldn't find ") printstyled(io, s, '\n', color=:cyan) print_correction(io, s) end -repl_corrections(s) = repl_corrections(STDOUT, s) +repl_corrections(s) = repl_corrections(stdout, s) # inverse of latex_symbols Dict, lazily created as needed const symbols_latex = Dict{String,String}() @@ -268,7 +268,7 @@ function repl_latex(io::IO, s::String) println(io, '\n') end end -repl_latex(s::String) = repl_latex(STDOUT, s) +repl_latex(s::String) = repl_latex(stdout, s) macro repl(ex) repl(ex) end macro repl(io, ex) repl(io, ex) end @@ -290,7 +290,7 @@ repl(io::IO, str::AbstractString) = :(apropos($io, $str)) repl(io::IO, other) = esc(:(@doc $other)) #repl(io::IO, other) = lookup_doc(other) # TODO -repl(x) = repl(STDOUT, x) +repl(x) = repl(stdout, x) function _repl(x) if (isexpr(x, :call) && !any(isexpr(x, :(::)) for x in x.args)) @@ -430,7 +430,7 @@ function printmatch(io::IO, word, match) end end -printmatch(args...) = printfuzzy(STDOUT, args...) +printmatch(args...) = printfuzzy(stdout, args...) function printmatches(io::IO, word, matches; cols = displaysize(io)[2]) total = 0 @@ -443,7 +443,7 @@ function printmatches(io::IO, word, matches; cols = displaysize(io)[2]) end end -printmatches(args...; cols = displaysize(STDOUT)[2]) = printmatches(STDOUT, args..., cols = cols) +printmatches(args...; cols = displaysize(stdout)[2]) = printmatches(stdout, args..., cols = cols) function print_joined_cols(io::IO, ss, delim = "", last = delim; cols = displaysize(io)[2]) i = 0 @@ -455,7 +455,7 @@ function print_joined_cols(io::IO, ss, delim = "", last = delim; cols = displays join(io, ss[1:i], delim, last) end -print_joined_cols(args...; cols = displaysize(STDOUT)[2]) = print_joined_cols(STDOUT, args...; cols=cols) +print_joined_cols(args...; cols = displaysize(stdout)[2]) = print_joined_cols(stdout, args...; cols=cols) function print_correction(io, word) cors = levsort(word, accessible(Main)) @@ -466,7 +466,7 @@ function print_correction(io, word) return end -print_correction(word) = print_correction(STDOUT, word) +print_correction(word) = print_correction(stdout, word) # Completion data @@ -566,7 +566,7 @@ stripmd(x::Markdown.Table) = Search through all documentation for a string, ignoring case. """ -apropos(string) = apropos(STDOUT, string) +apropos(string) = apropos(stdout, string) apropos(io::IO, string) = apropos(io, Regex("\\Q$string", "i")) function apropos(io::IO, needle::Regex) for mod in modules diff --git a/stdlib/REPL/test/TerminalMenus/radio_menu.jl b/stdlib/REPL/test/TerminalMenus/radio_menu.jl index 05d73605d2799..a8281271cd53d 100644 --- a/stdlib/REPL/test/TerminalMenus/radio_menu.jl +++ b/stdlib/REPL/test/TerminalMenus/radio_menu.jl @@ -33,6 +33,6 @@ TerminalMenus.config(charset=:unicode) TerminalMenus.writeLine(buf, radio_menu, 1, true) @test String(take!(buf)) == string(CONFIG[:cursor], " 1") -# Test using STDIN +# Test using stdin radio_menu = RadioMenu(string.(1:10)) @test simulateInput(3, radio_menu, :down, :down, :enter) diff --git a/stdlib/REPL/test/TerminalMenus/runtests.jl b/stdlib/REPL/test/TerminalMenus/runtests.jl index 5fe9e2bfb4957..9ef2b8340fc3c 100644 --- a/stdlib/REPL/test/TerminalMenus/runtests.jl +++ b/stdlib/REPL/test/TerminalMenus/runtests.jl @@ -6,7 +6,7 @@ TerminalMenus.config(supress_output=true) function simulateInput(expectedResult, menu::TerminalMenus.AbstractMenu, keys...) # If we cannot write to the buffer, skip the test - !(:buffer in fieldnames(typeof(STDIN))) && return true + !(:buffer in fieldnames(typeof(stdin))) && return true keydict = Dict(:up => "\e[A", :down => "\e[B", @@ -14,9 +14,9 @@ function simulateInput(expectedResult, menu::TerminalMenus.AbstractMenu, keys... for key in keys if isa(key, Symbol) - write(STDIN.buffer, keydict[key]) + write(stdin.buffer, keydict[key]) else - write(STDIN.buffer, "$key") + write(stdin.buffer, "$key") end end diff --git a/stdlib/REPL/test/repl.jl b/stdlib/REPL/test/repl.jl index 05d8c8c2a8bf5..c1ecb40c82ad8 100644 --- a/stdlib/REPL/test/repl.jl +++ b/stdlib/REPL/test/repl.jl @@ -158,7 +158,7 @@ fake_repl() do stdin_write, stdout_read, repl # issue #10120 # ensure that command quoting works correctly - let s, old_stdout = STDOUT + let s, old_stdout = stdout write(stdin_write, ";") readuntil(stdout_read, "shell> ") Base.print_shell_escaped(stdin_write, Base.julia_cmd().exec..., special=Base.shell_special) @@ -905,7 +905,7 @@ for (line, expr) in Pair[ "\"...\"" => "...", "r\"...\"" => Expr(:macrocall, Symbol("@r_str"), LineNumberNode(1, :none), "...") ] - #@test REPL._helpmode(line) == Expr(:macrocall, Expr(:., Expr(:., :Base, QuoteNode(:Docs)), QuoteNode(Symbol("@repl"))), LineNumberNode(119, doc_util_path), STDOUT, expr) + #@test REPL._helpmode(line) == Expr(:macrocall, Expr(:., Expr(:., :Base, QuoteNode(:Docs)), QuoteNode(Symbol("@repl"))), LineNumberNode(119, doc_util_path), stdout, expr) buf = IOBuffer() @test eval(Base, REPL._helpmode(buf, line)) isa Union{Markdown.MD,Nothing} end diff --git a/stdlib/Random/src/RNGs.jl b/stdlib/Random/src/RNGs.jl index 234b9b45c49ce..75fe31d85238c 100644 --- a/stdlib/Random/src/RNGs.jl +++ b/stdlib/Random/src/RNGs.jl @@ -239,7 +239,7 @@ function make_seed() try return rand(RandomDevice(), UInt32, 4) catch - println(STDERR, + println(stderr, "Entropy pool not available to seed RNG; using ad-hoc entropy sources.") seed = reinterpret(UInt64, time()) seed = hash(seed, UInt64(getpid())) diff --git a/stdlib/Test/src/Test.jl b/stdlib/Test/src/Test.jl index 0d6e87ac6feaa..3eb776b515f5f 100644 --- a/stdlib/Test/src/Test.jl +++ b/stdlib/Test/src/Test.jl @@ -527,7 +527,7 @@ contains_warn(output, S::Union{AbstractArray,Tuple}) = all(s -> contains_warn(ou """ @test_warn msg expr -Test whether evaluating `expr` results in [`STDERR`](@ref) output that contains +Test whether evaluating `expr` results in [`stderr`](@ref) output that contains the `msg` string or matches the `msg` regular expression. If `msg` is a boolean function, tests whether `msg(output)` returns `true`. If `msg` is a tuple or array, checks that the error output contains/matches each item in `msg`. @@ -556,7 +556,7 @@ end """ @test_nowarn expr -Test whether evaluating `expr` results in empty [`STDERR`](@ref) output +Test whether evaluating `expr` results in empty [`stderr`](@ref) output (no warnings or other messages). Returns the result of evaluating `expr`. """ macro test_nowarn(expr) @@ -680,7 +680,7 @@ function record(ts::DefaultTestSet, t::Union{Fail, Error}) # don't print the backtrace for Errors because it gets printed in the show # method if !isa(t, Error) - Base.show_backtrace(STDOUT, scrub_backtrace(backtrace())) + Base.show_backtrace(stdout, scrub_backtrace(backtrace())) end println() end @@ -698,7 +698,7 @@ function print_test_errors(ts::DefaultTestSet) for t in ts.results if (isa(t, Error) || isa(t, Fail)) && myid() == 1 println("Error in testset $(ts.description):") - Base.show(STDOUT,t) + Base.show(stdout,t) println() elseif isa(t, DefaultTestSet) print_test_errors(t) diff --git a/stdlib/Test/src/logging.jl b/stdlib/Test/src/logging.jl index 9dc8782a6a57c..b02bdadcd481c 100644 --- a/stdlib/Test/src/logging.jl +++ b/stdlib/Test/src/logging.jl @@ -86,7 +86,7 @@ function record(ts::DefaultTestSet, t::LogTestFailure) if myid() == 1 printstyled(ts.description, ": ", color=:white) print(t) - Base.show_backtrace(STDOUT, scrub_backtrace(backtrace())) + Base.show_backtrace(stdout, scrub_backtrace(backtrace())) println() end # Hack: convert to `Fail` so that test summarization works correctly diff --git a/stdlib/Test/test/runtests.jl b/stdlib/Test/test/runtests.jl index 8d21b7de74cb8..6a67e3ca06664 100644 --- a/stdlib/Test/test/runtests.jl +++ b/stdlib/Test/test/runtests.jl @@ -53,7 +53,7 @@ end end @testset "@test_warn" begin @test 1234 === @test_nowarn(1234) - @test 5678 === @test_warn("WARNING: foo", begin println(STDERR, "WARNING: foo"); 5678; end) + @test 5678 === @test_warn("WARNING: foo", begin println(stderr, "WARNING: foo"); 5678; end) let a @test_throws UndefVarError(:a) a @test_nowarn a = 1 @@ -204,8 +204,8 @@ end @test Test.finish(Test.FallbackTestSet()) !== nothing -OLD_STDOUT = STDOUT -OLD_STDERR = STDERR +OLD_STDOUT = stdout +OLD_STDERR = stderr catch_out = IOStream("") catch_err = IOStream("") rde, wre = redirect_stderr() @@ -393,7 +393,7 @@ catch end @test ts isa Test.DefaultTestSet -# now we're done running tests with DefaultTestSet so we can go back to STDOUT +# now we're done running tests with DefaultTestSet so we can go back to stdout redirect_stdout(OLD_STDOUT) redirect_stderr(OLD_STDERR) diff --git a/test/boundscheck.jl b/test/boundscheck.jl index a1ca1b8051536..09cc8d2cd13e8 100644 --- a/test/boundscheck.jl +++ b/test/boundscheck.jl @@ -3,16 +3,16 @@ # run boundscheck tests on separate workers launched with --check-bounds={default,yes,no} cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no boundscheck_exec.jl` -if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) +if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) error("boundscheck test failed, cmd : $cmd") end cmd = `$(Base.julia_cmd()) --check-bounds=yes --startup-file=no --depwarn=error boundscheck_exec.jl` -if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) +if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) error("boundscheck test failed, cmd : $cmd") end cmd = `$(Base.julia_cmd()) --check-bounds=no --startup-file=no --depwarn=error boundscheck_exec.jl` -if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) +if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) error("boundscheck test failed, cmd : $cmd") end diff --git a/test/channels.jl b/test/channels.jl index 84e1d35a8ddbb..ee278bb52466d 100644 --- a/test/channels.jl +++ b/test/channels.jl @@ -238,7 +238,7 @@ end GC.enable(true) GC.gc() end - oldstderr = STDERR + oldstderr = stderr local newstderr, errstream try newstderr = redirect_stderr() diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 0a51aed800fe7..897f33a3d61ad 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -173,19 +173,19 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no` # -g @test readchomp(`$exename -E "Base.JLOptions().debug_level" -g`) == "2" - let code = read(`$exename -g0 -i -e "code_llvm(STDOUT, +, (Int64, Int64), false, true); exit()"`, String) + let code = read(`$exename -g0 -i -e "code_llvm(stdout, +, (Int64, Int64), false, true); exit()"`, String) @test contains(code, "llvm.module.flags") @test !contains(code, "llvm.dbg.cu") @test !contains(code, "int.jl") @test !contains(code, "Int64") end - let code = read(`$exename -g1 -i -e "code_llvm(STDOUT, +, (Int64, Int64), false, true); exit()"`, String) + let code = read(`$exename -g1 -i -e "code_llvm(stdout, +, (Int64, Int64), false, true); exit()"`, String) @test contains(code, "llvm.module.flags") @test contains(code, "llvm.dbg.cu") @test contains(code, "int.jl") @test !contains(code, "Int64") end - let code = read(`$exename -g2 -i -e "code_llvm(STDOUT, +, (Int64, Int64), false, true); exit()"`, String) + let code = read(`$exename -g2 -i -e "code_llvm(stdout, +, (Int64, Int64), false, true); exit()"`, String) @test contains(code, "llvm.module.flags") @test contains(code, "llvm.dbg.cu") @test contains(code, "int.jl") @@ -275,7 +275,7 @@ let exename = `$(Base.julia_cmd()) --sysimage-native-code=yes --startup-file=no` # test passing arguments mktempdir() do dir testfile = joinpath(dir, tempname()) - # write a julia source file that just prints ARGS to STDOUT + # write a julia source file that just prints ARGS to stdout write(testfile, """ println(ARGS) """) diff --git a/test/core.jl b/test/core.jl index 0405a39f9f4a0..0f56aaa36b611 100644 --- a/test/core.jl +++ b/test/core.jl @@ -2559,7 +2559,7 @@ end === nothing # issue #10221 module GCbrokentype using InteractiveUtils -OLD_STDOUT = STDOUT +OLD_STDOUT = stdout fname = tempname() file = open(fname, "w") redirect_stdout(file) diff --git a/test/examples.jl b/test/examples.jl index 74c75030d300e..04d1b54d0025e 100644 --- a/test/examples.jl +++ b/test/examples.jl @@ -42,7 +42,7 @@ include(joinpath(dir, "queens.jl")) if Sys.isunix() script = joinpath(dir, "clustermanager/simple/test_simple.jl") cmd = `$(Base.julia_cmd()) --startup-file=no $script` - if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) && ccall(:jl_running_on_valgrind,Cint,()) == 0 + if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) && ccall(:jl_running_on_valgrind,Cint,()) == 0 error("UnixDomainCM failed test, cmd : $cmd") end end diff --git a/test/file.jl b/test/file.jl index 3fd32351032b8..6f18411f3a02a 100644 --- a/test/file.jl +++ b/test/file.jl @@ -1004,13 +1004,13 @@ function test_13559() write(x, 0xaa) end flush(x) - Test.@test read(STDIN, Int8) == 31 + Test.@test read(stdin, Int8) == 31 for i in 1:7 write(x, 0xaa) end close(x) """ - p = open(pipeline(`$(Base.julia_cmd()) --startup-file=no -e $writer_cmds`, stderr=STDERR), "w") + p = open(pipeline(`$(Base.julia_cmd()) --startup-file=no -e $writer_cmds`, stderr=stderr), "w") # quickly read FIFO, draining it and blocking but not failing with EOFError yet r = open(fn, "r") # 15 proper reads @@ -1040,11 +1040,11 @@ if !Sys.iswindows() && !(Sys.isbsd() && !Sys.isapple()) x = open($(repr(fn)), "w") write(x, 0x42) flush(x) - Test.@test read(STDIN, Int8) == 21 + Test.@test read(stdin, Int8) == 21 close(x) """ cmd = `$(Base.julia_cmd()) --startup-file=no -e $script` - p = open(pipeline(cmd, stderr=STDERR), "w") + p = open(pipeline(cmd, stderr=stderr), "w") r = open(fn, "r") @test read(r, Int8) == 66 diff --git a/test/meta.jl b/test/meta.jl index ffca57401490f..8c688d2cf8c77 100644 --- a/test/meta.jl +++ b/test/meta.jl @@ -159,7 +159,7 @@ end @test _nospec_with_default(10) == 20 -let oldout = STDOUT +let oldout = stdout local rdout, wrout, out try rdout, wrout = redirect_stdout() diff --git a/test/misc.jl b/test/misc.jl index 358dc7225a471..b309d6d15bbff 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -91,9 +91,9 @@ end @test GC.enable(true) # PR #10984 -# Disable on windows because of issue (missing flush) when redirecting STDERR. +# Disable on windows because of issue (missing flush) when redirecting stderr. let - redir_err = "redirect_stderr(STDOUT)" + redir_err = "redirect_stderr(stdout)" exename = Base.julia_cmd() script = "$redir_err; module A; f() = 1; end; A.f() = 1" warning_str = read(`$exename --warn-overwrite=yes --startup-file=no -e $script`, String) @@ -452,14 +452,14 @@ let buf_color = IOBuffer() @test String(take!(buf_color)) == "\e[31m\e[1mTwo\e[22m\e[39m\n\e[31m\e[1mlines\e[22m\e[39m" end -if STDOUT isa Base.TTY - @test haskey(STDOUT, :color) == true - @test haskey(STDOUT, :bar) == false - @test (:color=>Base.have_color) in STDOUT - @test (:color=>!Base.have_color) ∉ STDOUT - @test STDOUT[:color] == get(STDOUT, :color, nothing) == Base.have_color - @test get(STDOUT, :bar, nothing) === nothing - @test_throws KeyError STDOUT[:bar] +if stdout isa Base.TTY + @test haskey(stdout, :color) == true + @test haskey(stdout, :bar) == false + @test (:color=>Base.have_color) in stdout + @test (:color=>!Base.have_color) ∉ stdout + @test stdout[:color] == get(stdout, :color, nothing) == Base.have_color + @test get(stdout, :bar, nothing) === nothing + @test_throws KeyError stdout[:bar] end let @@ -597,7 +597,7 @@ include("testenv.jl") let flags = Cmd(filter(a->!contains(a, "depwarn"), collect(test_exeflags))) local cmd = `$test_exename $flags deprecation_exec.jl` - if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) + if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) error("Deprecation test failed, cmd : $cmd") end end diff --git a/test/ranges.jl b/test/ranges.jl index fa40fe50a285c..01edee15d84eb 100644 --- a/test/ranges.jl +++ b/test/ranges.jl @@ -906,7 +906,7 @@ end @testset "repr" begin # repr/show should display the range nicely # to test print_range in range.jl - replrepr(x) = repr("text/plain", x; context=IOContext(STDOUT, :limit=>true, :displaysize=>(24, 80))) + replrepr(x) = repr("text/plain", x; context=IOContext(stdout, :limit=>true, :displaysize=>(24, 80))) @test replrepr(1:4) == "1:4" @test repr("text/plain", 1:4) == "1:4" @test repr("text/plain", range(1, stop=5, length=7)) == "1.0:0.6666666666666666:5.0" diff --git a/test/runtests.jl b/test/runtests.jl index 3ab2adb505823..e1a36c521a26c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -109,11 +109,11 @@ cd(dirname(@__FILE__)) do local stdin_monitor all_tasks = Task[] try - if isa(STDIN, Base.TTY) + if isa(stdin, Base.TTY) t = current_task() - # Monitor STDIN and kill this task on ^C + # Monitor stdin and kill this task on ^C stdin_monitor = @async begin - term = REPL.Terminals.TTYTerminal("xterm", STDIN, STDOUT, STDERR) + term = REPL.Terminals.TTYTerminal("xterm", stdin, stdout, stderr) try REPL.Terminals.raw!(term, true) while true @@ -194,7 +194,7 @@ cd(dirname(@__FILE__)) do foreach(task->try; schedule(task, InterruptException(); error=true); end, all_tasks) foreach(wait, all_tasks) finally - if isa(STDIN, Base.TTY) + if isa(stdin, Base.TTY) schedule(stdin_monitor, InterruptException(); error=true) end end @@ -243,7 +243,7 @@ cd(dirname(@__FILE__)) do Test.pop_testset() elseif isa(res[2][1], RemoteException) && isa(res[2][1].captured.ex, Test.TestSetException) println("Worker $(res[2][1].pid) failed running test $(res[1]):") - Base.showerror(STDOUT,res[2][1].captured) + Base.showerror(stdout,res[2][1].captured) fake = Test.DefaultTestSet(res[1]) for i in 1:res[2][1].captured.ex.pass Test.record(fake, Test.Pass(:test, nothing, nothing, nothing)) diff --git a/test/show.jl b/test/show.jl index a08c1ddf8c85c..50a61e327f965 100644 --- a/test/show.jl +++ b/test/show.jl @@ -480,15 +480,15 @@ end @test_repr "Array{<:Real}" @test_repr "Array{>:Real}" -let oldout = STDOUT, olderr = STDERR +let oldout = stdout, olderr = stderr local rdout, wrout, rderr, wrerr, out, err, rd, wr, io try # pr 16917 rdout, wrout = redirect_stdout() - @test wrout === STDOUT + @test wrout === stdout out = @async read(rdout, String) rderr, wrerr = redirect_stderr() - @test wrerr === STDERR + @test wrerr === stderr err = @async read(rderr, String) @test dump(Int64) === nothing if !Sys.iswindows() @@ -496,7 +496,7 @@ let oldout = STDOUT, olderr = STDERR close(wrerr) end - for io in (Core.STDOUT, Core.STDERR) + for io in (Core.stdout, Core.stderr) Core.println(io, "TESTA") println(io, "TESTB") print(io, 'Α', 1) @@ -531,13 +531,13 @@ let filename = tempname() @test chomp(read(filename, String)) == "hello" ret = open(filename, "w") do f redirect_stderr(f) do - println(STDERR, "WARNING: hello") + println(stderr, "WARNING: hello") [2] end end @test ret == [2] - # STDIN is unavailable on the workers. Run test on master. + # stdin is unavailable on the workers. Run test on master. @test contains(read(filename, String), "WARNING: hello") ret = eval(Main, quote remotecall_fetch(1, $filename) do fname diff --git a/test/spawn.jl b/test/spawn.jl index ca9905310c626..bbcfa62617a08 100644 --- a/test/spawn.jl +++ b/test/spawn.jl @@ -93,7 +93,7 @@ end @test_broken success(ignorestatus(pipeline(falsecmd, falsecmd))) @test_broken success(ignorestatus(falsecmd & falsecmd)) -# STDIN Redirection +# stdin Redirection let file = tempname() run(pipeline(`$echocmd hello world`, file)) @test read(pipeline(file, catcmd), String) == "hello world\n" @@ -215,16 +215,16 @@ exename = Base.julia_cmd() if valgrind_off # If --trace-children=yes is passed to valgrind, we will get a # valgrind banner here, not "Hello World\n". - @test read(pipeline(`$exename --startup-file=no -e 'println(STDERR,"Hello World")'`, stderr=catcmd), String) == "Hello World\n" + @test read(pipeline(`$exename --startup-file=no -e 'println(stderr,"Hello World")'`, stderr=catcmd), String) == "Hello World\n" out = Pipe() - proc = spawn(pipeline(`$exename --startup-file=no -e 'println(STDERR,"Hello World")'`, stderr = out)) + proc = spawn(pipeline(`$exename --startup-file=no -e 'println(stderr,"Hello World")'`, stderr = out)) close(out.in) @test read(out, String) == "Hello World\n" @test success(proc) end # setup_stdio for AbstractPipe -let out = Pipe(), proc = spawn(pipeline(`$echocmd "Hello World"`, stdout=IOContext(out,STDOUT))) +let out = Pipe(), proc = spawn(pipeline(`$echocmd "Hello World"`, stdout=IOContext(out,stdout))) close(out.in) @test read(out, String) == "Hello World\n" @test success(proc) @@ -234,7 +234,7 @@ end @test run(pipeline(ignorestatus(falsecmd), truecmd)) === nothing @testset "redirect_*" begin - let OLD_STDOUT = STDOUT, + let OLD_STDOUT = stdout, fname = tempname(), f = open(fname,"w") @@ -243,7 +243,7 @@ end redirect_stdout(OLD_STDOUT) close(f) @test "Hello World\n" == read(fname, String) - @test OLD_STDOUT === STDOUT + @test OLD_STDOUT === stdout rm(fname) end end @@ -260,7 +260,7 @@ let fname = tempname(), p unsafe_store!(convert(Ptr{Cint}, handle + 2 * sizeof(Ptr{Cvoid})), 15) nothing end - OLD_STDERR = STDERR + OLD_STDERR = stderr redirect_stderr(open($(repr(fname)), "w")) # Usually this would be done by GC. Do it manually, to make the failure # case more reliable. @@ -272,7 +272,7 @@ let fname = tempname(), p import Base.zzzInvalidIdentifier """ try - io = open(pipeline(`$exename --startup-file=no`, stderr=STDERR), "w") + io = open(pipeline(`$exename --startup-file=no`, stderr=stderr), "w") write(io, cmd) close(io) wait(io) @@ -292,7 +292,7 @@ let bad = "bad\0name" end # issue #12829 -let out = Pipe(), echo = `$exename --startup-file=no -e 'print(STDOUT, " 1\t", read(STDIN, String))'`, ready = Condition(), t, infd, outfd +let out = Pipe(), echo = `$exename --startup-file=no -e 'print(stdout, " 1\t", read(stdin, String))'`, ready = Condition(), t, infd, outfd @test_throws ArgumentError write(out, "not open error") t = @async begin # spawn writer task open(echo, "w", out) do in1 @@ -369,7 +369,7 @@ let fname = tempname() else "cmd = pipeline(`echo asdf`, `cat`)" end) - for line in eachline(STDIN) + for line in eachline(stdin) run(cmd) end """ diff --git a/test/threads.jl b/test/threads.jl index 4aedadaf0a036..a05415b4dfe9c 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -27,7 +27,7 @@ function test_threaded_loop_and_atomic_add() # and were unique (via pigeon-hole principle). @test !(false in found) if was_inorder - println(STDERR, "Warning: threaded loop executed in order") + println(stderr, "Warning: threaded loop executed in order") end end @@ -463,7 +463,7 @@ test_nested_loops() ret void \"\"\", Cvoid, Tuple{Ptr{UInt128}, UInt128}, unsafe_convert(Ptr{UInt128}, x), v) end - code_native(STDOUT, unaligned_setindex!, Tuple{Atomic{UInt128}, UInt128}) + code_native(stdout, unaligned_setindex!, Tuple{Atomic{UInt128}, UInt128}) """ mktempdir() do dir