Skip to content

Commit e95f5f2

Browse files
dlmread: add deprecation warning for ignore_invalid_chars option
Part of #16107
1 parent b0575c0 commit e95f5f2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

base/datafmt.jl

+12-4
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,24 @@ end
289289
const valid_opts = [:header, :has_header, :use_mmap, :quotes, :comments, :dims, :comment_char, :skipstart, :skipblanks]
290290
const valid_opt_types = [Bool, Bool, Bool, Bool, Bool, NTuple{2,Integer}, Char, Integer, Bool]
291291
const deprecated_opts = Dict(:has_header => :header)
292+
292293
function val_opts(opts)
293294
d = Dict{Symbol,Union{Bool,NTuple{2,Integer},Char,Integer}}()
294295
for (opt_name, opt_val) in opts
295-
!in(opt_name, valid_opts) && throw(ArgumentError("unknown option $opt_name"))
296+
if opt_name == :ignore_invalid_chars
297+
Base.depwarn("the ignore_invalid_chars option is no longer supported and will be ignored", :val_opts)
298+
continue
299+
end
300+
in(opt_name, valid_opts) ||
301+
throw(ArgumentError("unknown option $opt_name"))
296302
opt_typ = valid_opt_types[findfirst(valid_opts, opt_name)]
297-
!isa(opt_val, opt_typ) && throw(ArgumentError("$opt_name should be of type $opt_typ, got $(typeof(opt_val))"))
303+
isa(opt_val, opt_typ) ||
304+
throw(ArgumentError("$opt_name should be of type $opt_typ, got $(typeof(opt_val))"))
298305
d[opt_name] = opt_val
299-
haskey(deprecated_opts, opt_name) && warn("$opt_name is deprecated, use $(deprecated_opts[opt_name]) instead")
306+
haskey(deprecated_opts, opt_name) &&
307+
Base.depwarn("$opt_name is deprecated, use $(deprecated_opts[opt_name]) instead", :val_opts)
300308
end
301-
d
309+
return d
302310
end
303311

304312
function dlm_fill(T::DataType, offarr::Vector{Vector{Int}}, dims::NTuple{2,Integer}, has_header::Bool, sbuff::String, auto::Bool, eol::Char)

0 commit comments

Comments
 (0)