Menu

#458 v0.17.22 crashes on long strings

closed
nobody
None
major
bug
2023-05-05
2023-05-05
Kyle Larose
No

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.

Discussion

  • Anthon van der Neut

    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.

     
  • Anthon van der Neut

    • status: open --> closed
     
  • Anthon van der Neut

    Fixed in 0.17.23

     
  • Kyle Larose

    Kyle Larose - 2023-05-05

    I can confirm that that fixes the problem for me. Thanks for the quick turnaround!

     

Log in to post a comment.

MongoDB Logo MongoDB