Skip to content

Commit

Permalink
Revert "Deprecate DevNull, STDIN, STDOUT, and STDERR to lowercase (#2…
Browse files Browse the repository at this point in the history
…5959)"

This reverts commit 446085a.
Lowercasing these identifiers conflicts with the statistical meaning of
`stderr`, i.e. the standard error. This is defined in StatsBase and
widely used.
  • Loading branch information
ararslan committed Mar 27, 2018
1 parent 029677a commit 1950846
Show file tree
Hide file tree
Showing 106 changed files with 432 additions and 444 deletions.
2 changes: 1 addition & 1 deletion DISTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,6 @@ 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`, `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`.

* `showcompact(io, x...)` has been deprecated in favor of
Expand All @@ -1128,6 +1125,8 @@ Deprecated or removed
* `isupper`, `islower`, `ucfirst` and `lcfirst` have been deprecated in favor of `isuppercase`,
`islowercase`, `uppercasefirst` and `lowercasefirst`, respectively ([#26442]).

* `wait` and `fetch` on `Task` now resemble the interface of `Future`

Command-line option changes
---------------------------

Expand Down Expand Up @@ -1436,4 +1435,4 @@ Command-line option changes
[#26286]: https://github.com/JuliaLang/julia/issues/26286
[#26436]: https://github.com/JuliaLang/julia/issues/26436
[#26442]: https://github.com/JuliaLang/julia/issues/26442
[#26600]: https://github.com/JuliaLang/julia/issues/26600
[#26600]: https://github.com/JuliaLang/julia/issues/26600
10 changes: 5 additions & 5 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,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)

Expand All @@ -468,9 +468,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
Expand Down
22 changes: 11 additions & 11 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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

Expand Down Expand Up @@ -328,7 +328,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
Expand Down Expand Up @@ -369,8 +369,8 @@ function __atreplinit(repl)
try
f(repl)
catch err
showerror(stderr, err)
println(stderr)
showerror(STDERR, err)
println(STDERR)
end
end
end
Expand All @@ -397,7 +397,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"
Expand All @@ -419,7 +419,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))
Expand All @@ -437,7 +437,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
Expand Down
8 changes: 4 additions & 4 deletions base/clipboard.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,7 +28,7 @@ elseif Sys.islinux() || Sys.KERNEL === :FreeBSD
global _clipboardcmd
_clipboardcmd !== nothing && return _clipboardcmd
for cmd in (:xclip, :xsel)
success(pipeline(`which $cmd`, devnull)) && return _clipboardcmd = cmd
success(pipeline(`which $cmd`, DevNull)) && return _clipboardcmd = cmd
end
pkgs = @static if Sys.islinux()
"xsel or xclip"
Expand All @@ -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
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/bootstrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let fs = Any[typeinf_ext, typeinf, typeinf_edge, pure_eval_call, optimize, run_p
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
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3827,7 +3827,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
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,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
Expand Down
12 changes: 6 additions & 6 deletions base/coreio.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# 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
const devnull = DevNullStream()
const DevNull = DevNullStream()
isreadable(::DevNullStream) = false
iswritable(::DevNullStream) = true
isopen(::DevNullStream) = true
Expand All @@ -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
21 changes: 7 additions & 14 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ macro deprecate_binding(old, new, export_old=true, dep_message=:nothing, constan
return Expr(:toplevel,
export_old ? Expr(:export, esc(old)) : nothing,
Expr(:const, Expr(:(=), esc(Symbol(string("_dep_message_",old))), esc(dep_message))),
constant ? Expr(:const, Expr(:(=), esc(old), esc(new))) : Expr(:(=), esc(old), esc(new)),
Expr(:const, Expr(:(=), esc(old), esc(new))),
Expr(:call, :deprecate, __module__, Expr(:quote, old)))
end

Expand Down Expand Up @@ -966,14 +966,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])
Expand Down Expand Up @@ -1023,19 +1023,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
Expand Down Expand Up @@ -1487,13 +1487,6 @@ function (r::Regex)(s)
occursin(r, s)
end

# Issue #25786
@deprecate_binding DevNull devnull
# TODO: When these are removed, also remove the uppercase variants in libuv.jl and stream.jl
@deprecate_binding STDIN stdin true nothing false
@deprecate_binding STDOUT stdout true nothing false
@deprecate_binding STDERR stderr true nothing false

# PR 25062
@deprecate(link_pipe(pipe; julia_only_read = true, julia_only_write = true),
link_pipe!(pipe, reader_supports_async = julia_only_read, writer_supports_async = julia_only_write),
Expand Down Expand Up @@ -1553,7 +1546,7 @@ end
@deprecate Crand Libc.rand false
@deprecate Csrand Libc.srand false

@deprecate showcompact(x) show(IOContext(stdout, :compact => true), x)
@deprecate showcompact(x) show(IOContext(STDOUT, :compact => true), x)
@deprecate showcompact(io, x) show(IOContext(io, :compact => true), x)
@deprecate sprint(::typeof(showcompact), args...) sprint(show, args...; context=:compact => true)

Expand Down
6 changes: 3 additions & 3 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -789,16 +789,16 @@ A variable referring to the last computed value, automatically set at the intera
kw"ans"

"""
devnull
DevNull
Used in a stream redirect to discard all data written to it. Essentially equivalent to
/dev/null on Unix or NUL on Windows. Usage:
```julia
run(pipeline(`cat test.txt`, devnull))
run(pipeline(`cat test.txt`, DevNull))
```
"""
devnull
DevNull

# doc strings for code in boot.jl and built-ins

Expand Down
2 changes: 1 addition & 1 deletion base/download.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else
global downloadcmd
if downloadcmd === nothing
for checkcmd in (:curl, :wget, :fetch)
if success(pipeline(`which $checkcmd`, devnull))
if success(pipeline(`which $checkcmd`, DevNull))
downloadcmd = checkcmd
break
end
Expand Down
2 changes: 1 addition & 1 deletion base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export
DenseMatrix,
DenseVecOrMat,
DenseVector,
DevNull,
Dict,
Dims,
Enum,
Expand Down Expand Up @@ -134,11 +135,10 @@ export
ENV,
LOAD_PATH,
PROGRAM_FILE,
stderr,
stdin,
stdout,
STDERR,
STDIN,
STDOUT,
VERSION,
devnull,

# Mathematical constants
Inf,
Expand Down
4 changes: 2 additions & 2 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ function _atexit()
try
f()
catch err
show(stderr, err)
println(stderr)
show(STDERR, err)
println(STDERR)
end
end
end
Loading

0 comments on commit 1950846

Please sign in to comment.