v0.17.22 crashes on long strings
ruamel.yaml is a YAML 1.2 parser/emitter for Python
Brought to you by:
anthon
After upgrading to ruamel.yaml v0.17.22 I started ruamel.yaml crashing when dumping documents which dumped properly in the past.
Perhaps the issue is with the fix for ticket #427 referenced in the changelog?
Repro:
from io import StringIO
from ruamel.yaml import YAML
def test_dump_fail():
yaml = YAML()
out_stream = StringIO()
in_string = "a" * 128
yaml.dump(in_string, out_stream)
result = out_stream.getvalue()
assert in_string == result.splitlines()[0]
def test_dump_pass():
yaml = YAML()
out_stream = StringIO()
in_string = "a" * 80 # Anything longer than this fails
yaml.dump(in_string, out_stream)
result = out_stream.getvalue()
assert in_string == result.splitlines()[0]
A simple workaround is the increase the width passed in to the dumper, but that still means that, whatever limit you choose, you'll still have a set of values which break. Further, it also means you can't use the wrapping functionality on shorter strings.
That is not good. I'll have a look at it this weekend. And yes it has most likely to do with 427, and don't recall anything else in 0.17.22 direcly affecting wrapping.
Thanks for reporting.
Fixed in 0.17.23
I can confirm that that fixes the problem for me. Thanks for the quick turnaround!