Skip to content

Commit 15a0a20

Browse files
committed
Merge pull request #62 from JuliaIO/yyc/0.5-depwarn
Fix depwarn on 0.5.
2 parents 97acc32 + 5532505 commit 15a0a20

File tree

9 files changed

+34
-26
lines changed

9 files changed

+34
-26
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ os:
55
julia:
66
- 0.3
77
- 0.4
8+
- nightly
89
notifications:
910
email: false
1011
script:

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
julia 0.3
2+
Compat 0.7.15
23
# The rest are needed only on julia 0.3
3-
Compat
44
Docile

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ environment:
22
matrix:
33
- JULIAVERSION: "julialang/bin/winnt/x86/0.3/julia-0.3-latest-win32.exe"
44
- JULIAVERSION: "julialang/bin/winnt/x64/0.3/julia-0.3-latest-win64.exe"
5+
- JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
6+
- JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
57
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
68
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
79

docs/make_docs.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using FileIO, Compat
2+
import Compat.String
23
import FileIO: LOAD, SAVE, OSX, OS
34
const fs = open(Pkg.dir("FileIO", "docs", "registry.md"), "w")
45

@@ -43,7 +44,7 @@ function add_format{Sym}(::Type{DataFormat{Sym}}, magic, extension, io_libs...)
4344
end
4445

4546

46-
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::@compat(Union{Tuple,AbstractVector,ByteString}), extension)
47+
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::@compat(Union{Tuple,AbstractVector,String}), extension)
4748
println(sym)
4849
end
4950

src/FileIO.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ VERSION >= v"0.4.0-dev+6641" && __precompile__()
22

33
module FileIO
44
using Compat
5+
import Compat.String
56

67
if VERSION < v"0.4.0-dev"
78
using Docile

src/error_handling.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
21
@doc """
32
`LoaderError` should be thrown when loader library code fails, and other libraries should
43
be given the chance to recover from the error. Reports the library name and an error message:
54
LoaderError("ImageMagick", "Foo not available")
65
""" ->
76
immutable LoaderError <: Exception
8-
library::UTF8String
9-
msg::UTF8String
7+
library::Compat.UTF8String
8+
msg::Compat.UTF8String
109
end
1110
Base.showerror(io::IO, e::LoaderError) = println(io, e.library, " load error: ",
1211
msg, "\n Will try next loader.")
@@ -17,8 +16,8 @@ be given the chance to recover from the error. Reports the library name and an
1716
WriterError("ImageMagick", "Foo not available")
1817
""" ->
1918
immutable WriterError <: Exception
20-
library::UTF8String
21-
msg::UTF8String
19+
library::Compat.UTF8String
20+
msg::Compat.UTF8String
2221
end
2322
Base.showerror(io::IO, e::WriterError) = println(
2423
io, e.library, " writer error: ",
@@ -30,7 +29,7 @@ Base.showerror(io::IO, e::WriterError) = println(
3029
""" ->
3130
immutable NotInstalledError <: Exception
3231
library::Symbol
33-
message::UTF8String
32+
message::Compat.UTF8String
3433
end
3534
Base.showerror(io::IO, e::NotInstalledError) = println(io, e.library, " is not installed.")
3635

src/query.jl

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ An easy way to write `DataFormat{:CSV}` is `format"CSV"`.
3939
immutable DataFormat{sym} end
4040

4141
macro format_str(s)
42-
:(DataFormat{$(Expr(:quote, symbol(s)))})
42+
:(DataFormat{$(Expr(:quote, @compat Symbol(s)))})
4343
end
4444

4545
const unknown_df = DataFormat{:UNKNOWN}
@@ -49,7 +49,7 @@ const unknown_df = DataFormat{:UNKNOWN}
4949
unknown(::Type{format"UNKNOWN"}) = true
5050
unknown{sym}(::Type{DataFormat{sym}}) = false
5151

52-
const ext2sym = Dict{ASCIIString, @compat(Union{Symbol,Vector{Symbol}})}()
52+
const ext2sym = Dict{String, @compat(Union{Symbol,Vector{Symbol}})}()
5353
const magic_list = Array(Pair, 0) # sorted, see magic_cmp below
5454
const sym2info = Dict{Symbol,Any}() # Symbol=>(magic, extension)
5555
const magic_func = Array(Pair, 0) # for formats with complex magic #s
@@ -73,7 +73,7 @@ For example:
7373
7474
Note that extensions, magic numbers, and format-identifiers are case-sensitive.
7575
""" ->
76-
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::@compat(Union{Tuple,AbstractVector,ByteString}), extension)
76+
function add_format{sym}(fmt::Type{DataFormat{sym}}, magic::@compat(Union{Tuple,AbstractVector,String}), extension)
7777
haskey(sym2info, sym) && error("format ", fmt, " is already registered")
7878
m = canonicalize_magic(magic)
7979
rng = searchsorted(magic_list, m, lt=magic_cmp)
@@ -155,11 +155,11 @@ Base.info{sym}(::Type{DataFormat{sym}}) = sym2info[sym]
155155

156156
canonicalize_magic{N}(m::NTuple{N,UInt8}) = m
157157
canonicalize_magic(m::AbstractVector{UInt8}) = tuple(m...)
158-
canonicalize_magic(m::ByteString) = canonicalize_magic(m.data)
158+
canonicalize_magic(m::String) = canonicalize_magic(m.data)
159159

160160

161161

162-
function add_extension(ext::ASCIIString, sym)
162+
function add_extension(ext::String, sym)
163163
if haskey(ext2sym, ext)
164164
v = ext2sym[ext]
165165
if isa(v, Symbol)
@@ -177,7 +177,7 @@ function add_extension(ext::@compat(Union{Array,Tuple}), sym)
177177
end
178178
end
179179

180-
del_extension(ext::ASCIIString) = delete!(ext2sym, ext)
180+
del_extension(ext::String) = delete!(ext2sym, ext)
181181
function del_extension(ext::@compat(Union{Array,Tuple}))
182182
for e in ext
183183
del_extension(e)
@@ -213,7 +213,7 @@ abstract Formatted{F<:DataFormat} # A specific file or stream
213213
DataFormat `fmt`. For example, `File{fmtpng}(filename)` would indicate a PNG
214214
file.""" ->
215215
immutable File{F<:DataFormat} <: Formatted{F}
216-
filename::UTF8String
216+
filename::Compat.UTF8String
217217
end
218218
File{sym}(fmt::Type{DataFormat{sym}}, filename) = File{fmt}(filename)
219219

@@ -236,10 +236,10 @@ indicate PNG format. If known, the optional `filename` argument can
236236
be used to improve error messages, etc.""" ->
237237
immutable Stream{F<:DataFormat,IOtype<:IO} <: Formatted{F}
238238
io::IOtype
239-
filename::Nullable{UTF8String}
239+
filename::Nullable{Compat.UTF8String}
240240
end
241241

242-
Stream{F<:DataFormat}(::Type{F}, io::IO) = Stream{F,typeof(io)}(io, Nullable{UTF8String}())
242+
Stream{F<:DataFormat}(::Type{F}, io::IO) = Stream{F,typeof(io)}(io, Nullable{Compat.UTF8String}())
243243
Stream{F<:DataFormat}(::Type{F}, io::IO, filename::AbstractString) = Stream{F,typeof(io)}(io,utf8(filename))
244244
Stream{F<:DataFormat}(::Type{F}, io::IO, filename) = Stream{F,typeof(io)}(io,filename)
245245
Stream{F}(file::File{F}, io::IO) = Stream{F,typeof(io)}(io,filename(file))
@@ -287,12 +287,15 @@ Base.eof(s::Stream) = eof(stream(s))
287287
Base.read!(s::Stream, array::Array) = read!(stream(s), array)
288288
@inline Base.write(s::Stream, args...) = write(stream(s), args...)
289289
# Note: we can't sensibly support the all keyword. If you need that,
290-
# call readbytes(stream(s), ...; all=value) manually
290+
# call read(stream(s), ...; all=value) manually
291291
Base.readbytes!(s::Stream, b) = readbytes!(stream(s), b)
292292
Base.readbytes!(s::Stream, b, nb) = readbytes!(stream(s), b, nb)
293-
Base.readbytes(s::Stream) = readbytes(stream(s))
294-
Base.readbytes(s::Stream, nb) = readbytes(stream(s), nb)
293+
Base.read(s::Stream) = read(stream(s))
294+
Base.read(s::Stream, nb) = read(stream(s), nb)
295295
Base.flush(s::Stream) = flush(stream(s))
296+
# 0.4 compat
297+
Base.readbytes(s::Stream) = read(stream(s))
298+
Base.readbytes(s::Stream, nb) = read(stream(s), nb)
296299

297300
Base.isreadonly(s::Stream) = isreadonly(stream(s))
298301
Base.isopen(s::Stream) = isopen(stream(s))
@@ -321,7 +324,7 @@ function skipmagic(io, magic::Tuple)
321324
len = position(io)
322325
seekstart(io)
323326
filter!(x-> length(x) <= len, magic) # throw out magic bytes that are longer than IO
324-
tmp = readbytes(io, length(first(magic))) # now, first is both the longest and guaranteed to fit into io, so we can just read the bytes
327+
tmp = read(io, length(first(magic))) # now, first is both the longest and guaranteed to fit into io, so we can just read the bytes
325328
for m in magic
326329
if magic_equal(m, tmp)
327330
seek(io, length(m))
@@ -382,7 +385,7 @@ hasfunction(s::Tuple) = false #has magic
382385
format inferred from the magic bytes.""" ->
383386
query(io::IO, filename) = query(io, Nullable(utf8(filename)))
384387

385-
function query(io::IO, filename::Nullable{UTF8String}=Nullable{UTF8String}())
388+
function query(io::IO, filename::Nullable{Compat.UTF8String}=Nullable{Compat.UTF8String}())
386389
magic = Array(UInt8, 0)
387390
pos = position(io)
388391
for p in magic_list

src/registry.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function detect_stlascii(io)
157157
len = position(io)
158158
seekstart(io)
159159
len < 80 && return false
160-
header = readbytes(io, 80) # skip header
160+
header = read(io, 80) # skip header
161161
seekstart(io)
162162
header[1:6] == b"solid " && !detect_stlbinary(io)
163163
finally

test/loadsave.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ context("Save") do
116116
@fact position(s) --> 1
117117
@fact isreadonly(s) --> true
118118
@fact isopen(s) --> true
119-
@fact readbytes(s, 2) --> b"UM"
119+
@fact read(s, 2) --> b"UM"
120120
end
121121
rm(fn)
122122

@@ -128,15 +128,16 @@ del_format(format"DUMMY")
128128
# PPM/PBM can be either binary or text. Test that the defaults work,
129129
# and that we can force a choice.
130130
module AmbigExt
131+
using Compat
131132
import FileIO: File, @format_str, Stream, stream, skipmagic
132133

133134
load(f::File{format"AmbigExt1"}) = open(f) do io
134135
skipmagic(io)
135-
readall(stream(io))
136+
readstring(stream(io))
136137
end
137138
load(f::File{format"AmbigExt2"}) = open(f) do io
138139
skipmagic(io)
139-
readall(stream(io))
140+
readstring(stream(io))
140141
end
141142

142143
save(f::File{format"AmbigExt1"}, testdata) = open(f, "w") do io

0 commit comments

Comments
 (0)