From 5815cf8fc628bf39943b60db2632abc9b3aea399 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Sat, 11 Feb 2017 16:46:57 -0500 Subject: [PATCH] Fix depwarn on 0.6 --- REQUIRE | 2 +- appveyor.yml | 2 +- src/ZMQ.jl | 15 +++++++++------ test/runtests.jl | 36 +++++++++++++++++++++--------------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/REQUIRE b/REQUIRE index a08e057..f65bfa3 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ julia 0.4 BinDeps 0.3.21 @osx Homebrew -Compat 0.9.5 +Compat 0.17.0 @windows WinRPM diff --git a/appveyor.yml b/appveyor.yml index 246b832..ec213a3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -34,7 +34,7 @@ install: build_script: # Need to convert from shallow to complete for Pkg.clone to work - IF EXIST .git\shallow (git fetch --unshallow) - - C:\projects\julia\bin\julia -F -e "versioninfo(); + - C:\projects\julia\bin\julia -e "versioninfo(); Pkg.clone(pwd(), \"ZMQ\"); Pkg.build(\"ZMQ\")" test_script: diff --git a/src/ZMQ.jl b/src/ZMQ.jl index cbe1c62..7b3e877 100644 --- a/src/ZMQ.jl +++ b/src/ZMQ.jl @@ -27,7 +27,7 @@ else end import Base: - convert, get, bytestring, + convert, get, length, size, stride, similar, getindex, setindex!, fd, wait, notify, close, connect, bind, send, recv @@ -353,7 +353,7 @@ function gc_free_fn(data::Ptr{Void}, hint::Ptr{Void}) end ## Messages ## -bitstype 64 * 8 MsgPadding +@compat primitive type MsgPadding 64 * 8 end type Message <: AbstractArray{UInt8,1} # Matching the declaration in the header: char _[64]; @@ -437,10 +437,13 @@ end # Convert message to string (copies data) unsafe_string(zmsg::Message) = Compat.unsafe_string(pointer(zmsg), length(zmsg)) -if VERSION < v"0.5-dev+4341" - bytestring(zmsg::Message) = unsafe_string(zmsg) -else - @deprecate bytestring(zmsg::Message) unsafe_string(zmsg::Message) +if isdefined(Base, :bytestring) + import Base: bytestring + if VERSION < v"0.5-dev+4341" + bytestring(zmsg::Message) = unsafe_string(zmsg) + else + @deprecate bytestring(zmsg::Message) unsafe_string(zmsg::Message) + end end # Build an IOStream from a message diff --git a/test/runtests.jl b/test/runtests.jl index 5ce6f8e..3223c6a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -83,19 +83,25 @@ ZMQ.close(s1) ZMQ.close(s2) ZMQ.close(ctx2) -# deprecate bytestring(::Message) -let olderr = STDERR - old_have_color = Base.have_color - eval(Base, :(have_color = false)) # avoid control characters in output - rderr, wrerr = redirect_stderr() - reader = @async readstring(rderr) - @assert bytestring(Message("hello")) == "hello" - redirect_stderr(olderr) - close(wrerr) - if VERSION < v"0.5-dev+4341" - @assert isempty(wait(reader)) - else - @assert contains(wait(reader), "WARNING: bytestring(zmsg::Message) is deprecated") - end - eval(Base, :(have_color = $old_have_color)) # avoid control characters in output +# deprecate bytestring(::Message), removed on 0.6 +isdefined(Base, :bytestring) && let olderr = STDERR + old_have_color = Base.have_color + eval(Base, :(have_color = false)) # avoid control characters in output + local rderr, wrerr, reader + try + rderr, wrerr = redirect_stderr() + reader = @async readstring(rderr) + @assert bytestring(Message("hello")) == "hello" + finally + # Switch the stderr back before letting the error propagate so that + # the error output won't be swallowed. + redirect_stderr(olderr) + close(wrerr) + eval(Base, :(have_color = $old_have_color)) # avoid control characters in output + end + if VERSION < v"0.5-dev+4341" + @assert isempty(wait(reader)) + else + @assert contains(wait(reader), "WARNING: bytestring(zmsg::Message) is deprecated") + end end