Skip to content

Commit

Permalink
Merge pull request #212 from JuliaLang/teh/limit_output
Browse files Browse the repository at this point in the history
Fix for removal of limit_output
  • Loading branch information
tkelman committed May 28, 2016
2 parents b2bb3ab + 0a3c29c commit ed24f23
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,26 @@ function rewrite_pairs_to_tuples!(expr::Expr)
return expr
end

# rewrites accesses to IOContext dicts
function rewrite_iocontext!(expr::Expr)
if expr.head == :call && expr.args[1] == :get
key = expr.args[3]
if (((isa(key, QuoteNode) && key.value == :limit) ||
(isa(key, Expr) && key.head == :quote && key.args[1] == :limit))
&& expr.args[4] == false)
if VERSION >= v"0.5.0-dev+1936" && VERSION < v"0.5.0-dev+4305"
expr.args[1] = :(Base.limit_output)
deleteat!(expr.args, 3:4)
elseif VERSION < v"0.5.0-dev+1936"
expr.head = :quote
expr.args[1] = false
deleteat!(expr.args, 3:4)
end
end
end
expr
end

if VERSION < v"0.4.0-dev+707"
macro inline(ex)
esc(ex)
Expand Down Expand Up @@ -515,6 +535,9 @@ function _compat(ex::Expr)
elseif VERSION < v"0.4.0-dev+1246" && f == :String
ex = Expr(:call, :bytestring, ex.args[2:end]...)
end
if VERSION < v"0.5.0-dev+4305"
rewrite_iocontext!(ex)
end
elseif ex.head === :curly
f = ex.args[1]
if VERSION < v"0.4.0-dev+4319" && f === :Tuple
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1183,3 +1183,6 @@ if VERSION < v"0.5.0-dev+4267"
else
@test Compat.KERNEL == Sys.KERNEL
end

io = IOBuffer()
@test @compat(get(io, :limit, false)) == false

0 comments on commit ed24f23

Please sign in to comment.