Round-trip fails on default settings
ruamel.yaml is a YAML 1.2 parser/emitter for Python
Brought to you by:
anthon
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.
Unable to reproduce this in 0.18.15.
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.