Skip to content

Commit

Permalink
Merge pull request #575 from JuliaLang/yyc/0.7
Browse files Browse the repository at this point in the history
Fix most of 0.7 depwarns
  • Loading branch information
yuyichao authored Jul 24, 2017
2 parents 26780fb + 2094819 commit 806cbf0
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 58 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ julia 0.5
MbedTLS 0.4.3
JSON 0.5
ZMQ 0.3.3
Compat 0.25.1
Compat 0.27.0
Conda 0.1.5
3 changes: 1 addition & 2 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#######################################################################
import JSON, Conda
using Compat
import Compat.String

jupyter=""

Expand All @@ -20,7 +19,7 @@ function prog_version(prog)
end
end

global jupyter = get(ENV, "JUPYTER", isfile("JUPYTER") ? readchomp("JUPYTER") : is_linux() ? "jupyter" : "")
global jupyter = get(ENV, "JUPYTER", isfile("JUPYTER") ? readchomp("JUPYTER") : Compat.Sys.islinux() ? "jupyter" : "")
jupyter_vers = isempty(jupyter) ? v"0.0" : prog_version(jupyter)
if (jupyter_vers == v"0.0") # some Linux distributions (Debian) use jupyter-notebook to launch Jupyter
jupyter_vers = prog_version(jupyter * "-notebook")
Expand Down
6 changes: 3 additions & 3 deletions deps/kspec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function installkernel(name::AbstractString, julia_options::AbstractString...;

juliakspec = joinpath(tempdir(), spec_name)
try
binary_name = is_windows() ? "julia.exe" : "julia"
binary_name = Compat.Sys.iswindows() ? "julia.exe" : "julia"
kernelcmd_array = String[joinpath(JULIA_HOME,"$binary_name"), "-i",
"--startup-file=yes", "--color=yes"]
append!(kernelcmd_array, julia_options)
Expand Down Expand Up @@ -75,13 +75,13 @@ function installkernel(name::AbstractString, julia_options::AbstractString...;
run(`$jupyter kernelspec install --replace --user $juliakspec`)
push!(kspec_cmd, jupyter, "kernelspec")
catch
@static if is_unix()
@static if Compat.Sys.isunix()
run(`$jupyter-kernelspec install --replace --user $juliakspec`)
push!(kspec_cmd, jupyter * "-kernelspec")
end

# issue #363:
@static if is_windows()
@static if Compat.Sys.iswindows()
jupyter_dir = dirname(jupyter)
jks_exe = ""
if jupyter_dir == abspath(Conda.SCRIPTDIR)
Expand Down
2 changes: 1 addition & 1 deletion src/IJulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ process manager.)
"""
function notebook(; dir=homedir(), detached=false)
inited && error("IJulia is already running")
if is_apple() # issue #551 workaround, remove after macOS 10.12.6 release?
if Compat.Sys.isapple() # issue #551 workaround, remove after macOS 10.12.6 release?
withenv("BROWSER"=>"open") do
p = spawn(Cmd(`$notebook_cmd`, detach=true, dir=dir))
end
Expand Down
2 changes: 0 additions & 2 deletions src/comm_manager.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module CommManager

using IJulia
using Compat
import Compat.String

import IJulia: Msg, uuid4, send_ipython, msg_pub

Expand Down
18 changes: 6 additions & 12 deletions src/execute_request.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,10 @@ function undisplay(x)
end

function show_bt(io::IO, top_func::Symbol, t, set)
if VERSION >= v"0.5.0-pre+5636" # julia PR #17570
# follow PR #17570 code in removing top_func from backtrace
eval_ind = findlast(addr->Base.REPL.ip_matches_func(addr, top_func), t)
eval_ind != 0 && (t = t[1:eval_ind-1])
Base.show_backtrace(io, t)
else
Base.show_backtrace(io, top_func, t, set)
end
# follow PR #17570 code in removing top_func from backtrace
eval_ind = findlast(addr->Base.REPL.ip_matches_func(addr, top_func), t)
eval_ind != 0 && (t = t[1:eval_ind-1])
Base.show_backtrace(io, t)
end

# wrapper for showerror(..., backtrace=false) since invokelatest
Expand Down Expand Up @@ -107,8 +103,6 @@ function helpcode(code::AbstractString)
# as in base/REPL.jl, special-case keywords so that they parse
if !haskey(Docs.keywords, Symbol(code_))
return "Base.Docs.@repl $code_"
elseif VERSION < v"0.5.0-dev+3831"
return "eval(:(Base.Docs.@repl \$(symbol(\"$code_\"))))"
else
return "eval(:(Base.Docs.@repl \$(Symbol(\"$code_\"))))"
end
Expand Down Expand Up @@ -143,7 +137,7 @@ function execute_request(socket, msg)
# "; ..." cells are interpreted as shell commands for run
code = replace(code, r"^\s*;.*$",
m -> string(replace(m, r"^\s*;", "Base.repl_cmd(`"),
"`, STDOUT)"), 0)
"`, STDOUT)"))

# a cell beginning with "? ..." is interpreted as a help request
hcode = replace(code, r"^\s*\?", "")
Expand All @@ -158,7 +152,7 @@ function execute_request(socket, msg)

#run the code!
ans = result = ismatch(magics_regex, code) ? magics_help(code) :
include_string(code, "In[$n]")
include_string(Main, code, "In[$n]")

if silent
result = nothing
Expand Down
2 changes: 1 addition & 1 deletion src/handlers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function rm_sideeffects(ex::Expr)
end
end
function docdict(s::AbstractString)
ex = macroexpand(parse(helpcode(s)))
ex = macroexpand(Main, parse(helpcode(s)))
# unfortunately, the REPL help macros sometimes have
# expressions with side effects (I/O), so we need to
# remove these.
Expand Down
50 changes: 23 additions & 27 deletions src/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,33 @@ immutable InlineDisplay <: Display end
# of preference (descending "richness")
const ipy_mime = [ "text/html", "text/latex", "image/svg+xml", "image/png", "image/jpeg", "text/plain", "text/markdown", "application/javascript" ]

if VERSION >= v"0.5.0-dev+4305" # JuliaLang/julia#16354
# need special handling for showing a string as a textmime
# type, since in that case the string is assumed to be
# raw data unless it is text/plain
israwtext(::MIME, x::AbstractString) = true
israwtext(::MIME"text/plain", x::AbstractString) = false
israwtext(::MIME, x) = false
# need special handling for showing a string as a textmime
# type, since in that case the string is assumed to be
# raw data unless it is text/plain
israwtext(::MIME, x::AbstractString) = true
israwtext(::MIME"text/plain", x::AbstractString) = false
israwtext(::MIME, x) = false

# convert x to a string of type mime, making sure to use an
# IOContext that tells the underlying show function to limit output
function limitstringmime(mime::MIME, x)
buf = IOBuffer()
if istextmime(mime)
if israwtext(mime, x)
return String(x)
else
show(IOContext(buf, limit=true), mime, x)
end
# convert x to a string of type mime, making sure to use an
# IOContext that tells the underlying show function to limit output
function limitstringmime(mime::MIME, x)
buf = IOBuffer()
if istextmime(mime)
if israwtext(mime, x)
return String(x)
else
b64 = Base64EncodePipe(buf)
if isa(x, Vector{UInt8})
write(b64, x) # x assumed to be raw binary data
else
show(IOContext(b64, limit=true), mime, x)
end
close(b64)
show(IOContext(buf, limit=true), mime, x)
end
return String(take!(buf))
else
b64 = Base64EncodePipe(buf)
if isa(x, Vector{UInt8})
write(b64, x) # x assumed to be raw binary data
else
show(IOContext(b64, limit=true), mime, x)
end
close(b64)
end
else
limitstringmime(mime::MIME, x) = stringmime(mime, x)
return String(take!(buf))
end

for mime in ipy_mime
Expand Down
2 changes: 1 addition & 1 deletion src/kernel.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import IJulia

# workaround #60:
if IJulia.Compat.is_apple()
if IJulia.Compat.Sys.isapple()
ENV["PATH"] = JULIA_HOME*":"*ENV["PATH"]
end

Expand Down
2 changes: 1 addition & 1 deletion src/stdio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ end
function oslibuv_flush()
#refs: https://github.com/JuliaLang/IJulia.jl/issues/347#issuecomment-144505862
# https://github.com/JuliaLang/IJulia.jl/issues/347#issuecomment-144605024
@static if is_windows()
@static if Compat.Sys.iswindows()
ccall(:SwitchToThread, stdcall, Void, ())
end
yield()
Expand Down
1 change: 0 additions & 1 deletion test/comm.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Base.Test
using Compat
import IJulia: Comm, comm_target


Expand Down
6 changes: 1 addition & 5 deletions test/execute_request.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import IJulia: helpcode, error_content
@test "Base.Docs.@repl +" == helpcode("+")

@test haskey(Docs.keywords, :import)
if VERSION < v"0.5.0-dev+3831"
@test """eval(:(Base.Docs.@repl \$(symbol("import"))))""" == helpcode("import")
else
@test """eval(:(Base.Docs.@repl \$(Symbol("import"))))""" == helpcode("import")
end
@test """eval(:(Base.Docs.@repl \$(Symbol("import"))))""" == helpcode("import")

content = error_content(UndefVarError(:a))
@test "UndefVarError" == content["ename"]
Expand Down
1 change: 0 additions & 1 deletion test/msg.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Base.Test
using Compat
import IJulia: Msg

idents = ["idents"]
Expand Down

0 comments on commit 806cbf0

Please sign in to comment.