Skip to content

Commit

Permalink
Merge pull request #135 from yuyichao/yyc/0.6
Browse files Browse the repository at this point in the history
Fix depwarn on 0.6
  • Loading branch information
yuyichao authored Feb 14, 2017
2 parents 7f51abc + 5815cf8 commit 65112c3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
julia 0.4
BinDeps 0.3.21
@osx Homebrew
Compat 0.9.5
Compat 0.17.0
@windows WinRPM
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 9 additions & 6 deletions src/ZMQ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down
36 changes: 21 additions & 15 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 65112c3

Please sign in to comment.