Skip to content

Commit

Permalink
Rename STD(IN|OUT|ERR) to their lowercase equivalents
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan authored and JeffBezanson committed Feb 23, 2018
1 parent 91f0f9d commit 06c8e34
Show file tree
Hide file tree
Showing 87 changed files with 322 additions and 313 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
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,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`

Expand Down
10 changes: 5 additions & 5 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
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 @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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))
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 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 Down Expand Up @@ -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],
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 @@ -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
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions base/coreio.jl
Original file line number Diff line number Diff line change
@@ -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
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
18 changes: 11 additions & 7 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ end

deprecate(m::Module, s::Symbol, flag=1) = ccall(:jl_deprecate_binding, Cvoid, (Any, Any, Cint), m, s, flag)

macro deprecate_binding(old, new, export_old=true, dep_message=nothing)
macro deprecate_binding(old, new, export_old=true, dep_message=nothing, constant=true)
dep_message == nothing && (dep_message = ", use $new instead.")
return Expr(:toplevel,
export_old ? Expr(:export, esc(old)) : nothing,
Expr(:const, Expr(:(=), esc(Symbol(string("_dep_message_",old))), esc(dep_message))),
Expr(:const, Expr(:(=), esc(old), esc(new))),
constant ? Expr(:const, Expr(:(=), esc(old), esc(new))) : Expr(:(=), esc(old), esc(new)),
Expr(:call, :deprecate, __module__, Expr(:quote, old)))
end

Expand Down Expand Up @@ -961,14 +961,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 @@ -1018,19 +1018,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 @@ -1438,6 +1438,10 @@ 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),
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
6 changes: 3 additions & 3 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ export
ENV,
LOAD_PATH,
PROGRAM_FILE,
STDERR,
STDIN,
STDOUT,
stderr,
stdin,
stdout,
VERSION,
devnull,

Expand Down
4 changes: 2 additions & 2 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ function _atexit()
try
f()
catch err
show(STDERR, err)
println(STDERR)
show(stderr, err)
println(stderr)
end
end
end
16 changes: 8 additions & 8 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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 ##

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 06c8e34

Please sign in to comment.