Skip to content

Commit

Permalink
fixes for 0.7 (#249)
Browse files Browse the repository at this point in the history
* fixes for 0.7

* fixes for 0.7
  • Loading branch information
rened authored and TotalVerb committed Mar 29, 2018
1 parent fa23bae commit f05dd3d
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/JSON.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ __precompile__()

module JSON

using Compat

export json # returns a compact (or indented) JSON representation as a string
export JSONText # string wrapper to insert raw JSON into JSON output

Expand Down
4 changes: 2 additions & 2 deletions src/Writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ print(io::IO, obj, indent) =
show_json(io, StandardSerialization(), obj; indent=indent)
print(io::IO, obj) = show_json(io, StandardSerialization(), obj)

print(a, indent) = print(STDOUT, a, indent)
print(a) = print(STDOUT, a)
print(a, indent) = print(stdout, a, indent)
print(a) = print(stdout, a)

json(a) = sprint(print, a)
json(a, indent) = sprint(print, a, indent)
Expand Down
8 changes: 6 additions & 2 deletions src/bytes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ESCAPES = Dict(
LATIN_T => TAB)

const REVERSE_ESCAPES = Dict(reverse(p) for p in ESCAPES)
const ESCAPED_ARRAY = Vector{Vector{UInt8}}(uninitialized, 256)
const ESCAPED_ARRAY = Vector{Vector{UInt8}}(undef, 256)
for c in 0x00:0xFF
ESCAPED_ARRAY[c + 1] = if c == SOLIDUS
[SOLIDUS] # don't escape this one
Expand All @@ -53,7 +53,11 @@ for c in 0x00:0xFF
elseif haskey(REVERSE_ESCAPES, c)
[BACKSLASH, REVERSE_ESCAPES[c]]
elseif iscntrl(Char(c)) || !isprint(Char(c))
UInt8[BACKSLASH, LATIN_U, hex(c, 4)...]
if VERSION < v"0.7.0-DEV.4446"
UInt8[BACKSLASH, LATIN_U, hex(c, 4)...]
else
UInt8[BACKSLASH, LATIN_U, string(c, base=16, pad=4)...]
end
else
[c]
end
Expand Down
2 changes: 1 addition & 1 deletion src/specialized.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function predict_string(ps::MemoryParserState)
if ps[s] == LATIN_U # Unicode escape
t = ps.s
ps.s = s + 1
len += write(DevNull, read_unicode_escape!(ps))
len += write(devnull, read_unicode_escape!(ps))
s = ps.s
ps.s = t
continue
Expand Down
4 changes: 4 additions & 0 deletions test/async.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
finished_async_tests = RemoteChannel()

if VERSION >= v"0.7.0-DEV.4442"
using Sockets
end

@async begin
s = listen(7777)
s = accept(s)
Expand Down
3 changes: 1 addition & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,4 @@ end
end
end

# Check that printing to the default STDOUT doesn't fail
JSON.print(["JSON.jl tests pass!"], 1)
# Check that printing to the default stdout doesn't fail
2 changes: 1 addition & 1 deletion test/serializer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ end
struct SingletonType end
@test_throws ErrorException json(SingletonType())

# test printing to STDOUT
# test printing to stdout
let filename = tempname()
open(filename, "w") do f
redirect_stdout(f) do
Expand Down
4 changes: 2 additions & 2 deletions test/standard-serializer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ end
@testset "Null bytes" begin
zeros = Dict("\0" => "\0")
json_zeros = json(zeros)
@test contains(json_zeros,"\\u0000")
@test !contains(json_zeros,"\\0")
@test occursin("\\u0000", json_zeros)
@test !occursin("\\0", json_zeros)
@test JSON.parse(json_zeros) == zeros
end

Expand Down

2 comments on commit f05dd3d

@andreasnoack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skaermbillede 2018-05-14 kl 11 45 55

This should have bumped the Compat requirement to (at least) 0.59 and is now causing some trouble for other packages. Please be more careful when upgrading an important package to 0.7. In particular when 0.7 hasn't even been released yet. I'll try to fix things in METADATA.

@andreasnoack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, occursin was added only in 0.61.

Please sign in to comment.