Skip to content

Commit

Permalink
Read the whole file into memory
Browse files Browse the repository at this point in the history
when parsing multi-document files. Since parsing is lazy, just using
`do` results in the file being closed before parsing happens. Leaving
the file open and wating for the finalizer to close it was deemed
undesirable.
  • Loading branch information
contradict committed Aug 8, 2024
1 parent 67dd8dd commit 566c4fa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/YAML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,8 @@ load_file(filename::AbstractString, args...; kwargs...) =
Parse the YAML file `filename`, and return corresponding YAML documents.
"""
load_all_file(filename::AbstractString, args...; kwargs...) =
load_all(open(filename, "r"), args...; kwargs...)
open(filename, "r") do f
io = IOBuffer(read(f))
load_all(io, args...; kwargs...)
end
end # module

0 comments on commit 566c4fa

Please sign in to comment.