Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_all fails on Windows #132

Closed
swyant opened this issue May 11, 2023 · 3 comments · Fixed by #218
Closed

load_all fails on Windows #132

swyant opened this issue May 11, 2023 · 3 comments · Fixed by #218
Labels

Comments

@swyant
Copy link

swyant commented May 11, 2023

Given a YAML file like:

---
creator: LAMMPS
timestep: 0
...
---
creator: LAMMPS
timestep: 1
...

the following code:

julia> import YAML
julia> for fs in YAML.load_all(open("test.yaml"))
           @show fs
       end

results in

fs = Dict{Any, Any}("creator" => "LAMMPS", "timestep" => 0)
ERROR: AssertionError: typeof(forward!(composer.input)) == DocumentStartEvent

This issue only happens on Windows (specifically Windows 11), but works fine on Mac and Linux.

Thanks for any help!

@Paalon
Copy link
Contributor

Paalon commented Jun 17, 2024

This seems not solved yet.

IMG_5583

@Paalon
Copy link
Contributor

Paalon commented Jun 17, 2024

At 5bb060a,

WIndows (CRLF)

load_all_file

julia> docs = YAML.load_all_file("test/issue132.yaml");

julia> for doc in docs
           @show doc
       end
doc = Dict{Any, Any}("creator" => "LAMMPS", "timestep" => 0)
julia> docs = YAML.load_all_file("test/issue132.yaml");

julia> for doc in docs
           @show doc
       end
doc = Dict{Any, Any}("creator" => "LAMMPS", "timestep" => 0)
ERROR: AssertionError: forward!(composer.input) isa DocumentStartEvent
Stacktrace:
 [1] compose_document(composer::YAML.Composer)
   @ YAML C:\Users\paalon\git\YAML.jl\src\composer.jl:44
 [2] compose(events::YAML.EventStream, resolver::YAML.Resolver)
   @ YAML C:\Users\paalon\git\YAML.jl\src\composer.jl:33
 [3] load(tokenstream::YAML.TokenStream, constructor::YAML.Constructor)
   @ YAML C:\Users\paalon\git\YAML.jl\src\YAML.jl:69
 [4] next(it::YAML.YAMLDocIterator, state::Nothing)
   @ YAML C:\Users\paalon\git\YAML.jl\src\YAML.jl:112
 [5] iterate
   @ YAML C:\Users\paalon\git\YAML.jl\src\YAML.jl:121 [inlined]
⋮

macOS (LF)

load_all_file

julia> docs = YAML.load_all_file("test/issue132.yaml");

julia> for doc in docs
           @show doc
       end
doc = Dict{Any, Any}("creator" => "LAMMPS", "timestep" => 0)

load_all

julia> open("test/issue132.yaml", "r") do io
           docs = YAML.load_all(io)
           for doc in docs
               @show doc
           end
       end
doc = Dict{Any, Any}("creator" => "LAMMPS", "timestep" => 0)
doc = Dict{Any, Any}("creator" => "LAMMPS", "timestep" => 1)

macOS (CRLF)

load_all_file

julia> docs = YAML.load_all_file("test/issue132-crlf.yaml");

julia> for doc in docs
           @show doc
       end
doc = Dict{Any, Any}("creator" => "LAMMPS", "timestep" => 0)

load_all

julia> open("test/issue132-crlf.yaml", "r") do io
           docs = YAML.load_all(io)
           for doc in docs
               @show doc
           end
       end
doc = Dict{Any, Any}("creator" => "LAMMPS", "timestep" => 0)
ERROR: AssertionError: forward!(composer.input) isa DocumentStartEvent
Stacktrace:
 [1] compose_document(composer::YAML.Composer)
   @ YAML ~/git/YAML.jl/src/composer.jl:44
 [2] compose(events::YAML.EventStream, resolver::YAML.Resolver)
   @ YAML ~/git/YAML.jl/src/composer.jl:33
 [3] load(tokenstream::YAML.TokenStream, constructor::YAML.Constructor)
   @ YAML ~/git/YAML.jl/src/YAML.jl:69
 [4] next(it::YAML.YAMLDocIterator, state::Nothing)
   @ YAML ~/git/YAML.jl/src/YAML.jl:112
 [5] iterate
   @ ~/git/YAML.jl/src/YAML.jl:121 [inlined]
 [6] (::var"#5#6")(io::IOStream)
   @ Main ./REPL[12]:5
 [7] open(::var"#5#6", ::String, ::Vararg{String}; kwargs::@Kwargs{})
   @ Base ./io.jl:396
 [8] open(::Function, ::String, ::String)
   @ Base ./io.jl:393
 [9] top-level scope
   @ REPL[12]:1

@Paalon
Copy link
Contributor

Paalon commented Jun 19, 2024

From #214. This is really not OS specific but about \r\n:

julia> first(YAML.load_all("---\r\nx:\r\n...\r\n"))
ERROR: AssertionError: forward!(composer.input) isa DocumentStartEvent
Stacktrace:
 [1] compose_document(composer::YAML.Composer)
   @ YAML ~/git/YAML.jl/src/composer.jl:44
 [2] compose(events::YAML.EventStream, resolver::YAML.Resolver)
   @ YAML ~/git/YAML.jl/src/composer.jl:33
 [3] load(tokenstream::YAML.TokenStream, constructor::YAML.Constructor)
   @ YAML ~/git/YAML.jl/src/YAML.jl:69
 [4] next(it::YAML.YAMLDocIterator, state::Nothing)
   @ YAML ~/git/YAML.jl/src/YAML.jl:112
 [5] iterate
   @ ~/git/YAML.jl/src/YAML.jl:120 [inlined]
 [6] first(itr::YAML.YAMLDocIterator)
   @ Base ./abstractarray.jl:472
 [7] top-level scope
   @ REPL[71]:1

@kescobo kescobo linked a pull request Jun 25, 2024 that will close this issue
kescobo pushed a commit that referenced this issue Jun 25, 2024
* Add tests for issue 132.

* Add `.gitattributes` to prevent uninteded EOL newlines conversion by
Git.

- Fix EOL for normal test YAML files LF.
- With postfix `.crlf.yaml` files are use CRLF.
- Change windows_newlines content from `"hello:\r\n\r"` to `"hello:\r\n"`.

* Add expected data for tests issue 132.

* Fix LF to CRLF.
GunnarFarneback added a commit to GunnarFarneback/YAML.jl that referenced this issue Jun 28, 2024
GunnarFarneback added a commit to GunnarFarneback/YAML.jl that referenced this issue Jun 28, 2024
…er files. Revise an in-memory test of JuliaData#132 to actually test windows newlines. Add back revision of windows_newlines.yaml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants