Menu

#526 Round-trip fails on default settings

open
nobody
None
major
bug
2025-08-24
2024-09-09
d.schmid
No

Minimal example:

from io import StringIO
from ruamel.yaml import YAML

json = "\n".join("many lines" for _ in range(8))
yaml = YAML()
stream = StringIO()
yaml.dump(json, stream)
got = yaml.load(stream.getvalue())

print(f"got ={got!r}")
print(f"want={json!r}")
assert got == json

Versions:
Python 3.8.10
ruamel.yaml 0.18.6
ruamel.yaml.clib 0.2.8
windows 10.0.19045 Build 19045

This bug differs crucially from https://sourceforge.net/p/ruamel-yaml/tickets/493/ and https://sourceforge.net/p/ruamel-yaml/tickets/497/ as the preserve_quotes flag does not have to be set.
This also happens when a string like this is nested as an object value.

Discussion

  • Peter L Jones

    Peter L Jones - 2025-08-24

    Unable to reproduce this in 0.18.15.

     
  • d.schmid

    d.schmid - 2025-08-24

    This seems to be a windows-specifc bug. I'm able to reproduce this in 0.18.15 on windows but not on linux. maybe something about line-endings.

     

Log in to post a comment.