@@ -34,6 +34,7 @@ function checked_import(pkg::Symbol)
34
34
end
35
35
end
36
36
37
+ applicable_error (applicable, sym) = error (" No $applicable found for $sym " )
37
38
38
39
for (applicable_, add_, dict_) in (
39
40
(:applicable_loaders , :add_loader , :sym2loader ),
@@ -44,7 +45,7 @@ for (applicable_, add_, dict_) in (
44
45
if haskey ($ dict_, sym)
45
46
return $ dict_[sym]
46
47
end
47
- error ( " No $( $ applicable_) found for $( sym) " )
48
+ Base . invokelatest (applicable_error, $ applicable_, sym)
48
49
end
49
50
function $add_ (@nospecialize (fmt:: Type{<:DataFormat} ), pkg:: Symbol )
50
51
sym = formatname (fmt)
@@ -182,14 +183,18 @@ end
182
183
# Handlers for formatted files/streams
183
184
184
185
for fn in (:load , :loadstreaming , :metadata )
186
+ fn_func_name = Symbol (fn, " _filename" )
185
187
gen2_func_name = Symbol (" fileio_" , fn)
186
188
@eval function $fn (@nospecialize (q:: Formatted ), @nospecialize (args... ); @nospecialize (options... ))
189
+ Base. invokelatest ($ fn_func_name, q, filename (q), args... ; options... )
190
+ end
191
+ @eval function $fn_func_name (@nospecialize (q:: Formatted ), filename, @nospecialize (args... ); @nospecialize (options... ))
187
192
if unknown (q)
188
- isfile (filename (q)) || open (filename (q) ) # force systemerror
193
+ isfile (filename) || open (filename) # force systemerror
189
194
throw (UnknownFormat (q))
190
195
end
191
196
if q isa File
192
- ! isfile (filename (q)) && throw (ArgumentError (" No file exists at given path: $(filename (q) ) " ))
197
+ ! isfile (filename) && throw (ArgumentError (" No file exists at given path: $(filename) " ))
193
198
end
194
199
libraries = applicable_loaders (q)
195
200
failures = Any[]
@@ -207,7 +212,7 @@ for fn in (:load, :loadstreaming, :metadata)
207
212
push! (failures, (e, q))
208
213
end
209
214
end
210
- handle_exceptions (failures, " loading $(repr (filename (q) )) " )
215
+ handle_exceptions (failures, " loading $(repr (filename)) " )
211
216
end
212
217
end
213
218
0 commit comments