From 9ef71a31d8c41c42b954670cea0bf1efd60f6340 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Tue, 5 Dec 2017 10:40:31 +0100 Subject: [PATCH] IOContext(::IO, ::Pair, ::Pair...) --- README.md | 4 ++++ src/Compat.jl | 7 +++++++ test/runtests.jl | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/README.md b/README.md index a873cce33..e5dcc0d4a 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). +* `IOContext` accepting key-value `Pair`s ([#23271]). + ## Renaming @@ -358,6 +360,7 @@ includes this fix. Find the minimum version from there. [#22864]: https://github.com/JuliaLang/julia/issues/22864 [#23051]: https://github.com/JuliaLang/julia/issues/23051 [#23235]: https://github.com/JuliaLang/julia/issues/23235 +[#23271]: https://github.com/JuliaLang/julia/issues/23271 [#23427]: https://github.com/JuliaLang/julia/issues/23427 [#23570]: https://github.com/JuliaLang/julia/issues/23570 [#23666]: https://github.com/JuliaLang/julia/issues/23666 @@ -367,6 +370,7 @@ includes this fix. Find the minimum version from there. [#23931]: https://github.com/JuliaLang/julia/issues/23931 [#24047]: https://github.com/JuliaLang/julia/issues/24047 [#24282]: https://github.com/JuliaLang/julia/issues/24282 +[#24361]: https://github.com/JuliaLang/julia/issues/24361 [#24372]: https://github.com/JuliaLang/julia/issues/24372 [#24459]: https://github.com/JuliaLang/julia/issues/24459 [#24605]: https://github.com/JuliaLang/julia/issues/24605 diff --git a/src/Compat.jl b/src/Compat.jl index c580a057a..59be2a900 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -807,6 +807,13 @@ end (::Type{Array{T}}){T}(s::UniformScaling, m::Integer, n::Integer) = Matrix{T}(s, m, n) end +# https://github.com/JuliaLang/julia/pull/23271 +@static if VERSION < v"0.7.0-DEV.1472" + Base.IOContext(io::IO, arg1::Pair, arg2::Pair, args::Pair...) = IOContext(IOContext(io, arg1), arg2, args...) + # needed for ambiguity resolution + Base.IOContext(io::IOContext, arg1::Pair, arg2::Pair) = IOContext(IOContext(io, arg1), arg2) +end + # 0.7.0-DEV.2581 @static if !isdefined(Base, :Uninitialized) if VERSION >= v"0.6.0" diff --git a/test/runtests.jl b/test/runtests.jl index 7f57e13e8..8538080b9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -912,6 +912,10 @@ end @test isa(Array{Float64}(uninitialized, 2, 2), Matrix{Float64}) @test isa(Array{Float64,3}(uninitialized, 2, 2, 2), Array{Float64,3}) +# 0.7.0-DEV.1472 +@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true, :arg3=>true), :arg3, false) +@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true), :arg2, false) + # 0.7.0-DEV.2338 module Test24361 using Compat