Skip to content

Version 5.1 dumps strings differently on different platforms #275

@undera

Description

@undera

After 5.1 has been released, our CI builds started to fail. The reason is different outputs on Linux, Mac and Windows, depending on Python version.
The problem displays as different way to dump string containing tabs, on different platforms. I'd accept any of dump variants from 5.1 if it would be consistent across platforms. But having it different creates a mess with automated tests.

I have made simple unit test to reproduce the problem (Blazemeter/taurus#1076). The code to reproduce is:

class MyTestCase(unittest.TestCase):
    def test_case(self):
        data = {"str": "\tpart1\tpart2\t"}
        res = yaml.safe_dump(data,
                             default_flow_style=False, explicit_start=True, canonical=False,
                             allow_unicode=True, encoding='utf-8', width=float("inf"))
        res = res.decode('utf8')
        self.assertEqual('---\nstr: "\\tpart1\\tpart2\\t\"\n', res)

This test works fine on Linux with any Python version, Windows with Python 3.
It fails on MacOS with Python 2.7 and on Windows with Python 2.7.

I double-checked that version of PyYAML is 5.1 on all builds.

Relevant CI links:
Linux and Mac: https://travis-ci.org/Blazemeter/taurus/builds/507459846
Windows: https://ci.appveyor.com/project/undera/taurus/builds/23134929

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions