From be26179719f4a26ae6bf4f562508c5588daf0cef Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Wed, 10 Jun 2015 10:30:55 -0400 Subject: [PATCH] Fix monkey yaml's handling of carriage return monkeyYaml didn't split lines correctly leading to \r in resulting values. Fixes #295 --- tools/packaging/monkeyYaml.py | 2 +- tools/packaging/test/test_monkeyYaml.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/packaging/monkeyYaml.py b/tools/packaging/monkeyYaml.py index 8ce33f74b1..85e1ae1940 100644 --- a/tools/packaging/monkeyYaml.py +++ b/tools/packaging/monkeyYaml.py @@ -16,7 +16,7 @@ mYamlMultilineList = re.compile(r"^ *- (.*)$") def load(str): dict = None - lines = str.split("\n") + lines = str.splitlines() while lines: line = lines.pop(0) if myIsAllSpaces(line): diff --git a/tools/packaging/test/test_monkeyYaml.py b/tools/packaging/test/test_monkeyYaml.py index a16cd26609..c0800e35a7 100644 --- a/tools/packaging/test/test_monkeyYaml.py +++ b/tools/packaging/test/test_monkeyYaml.py @@ -106,6 +106,10 @@ class TestMonkeyYAMLParsing(unittest.TestCase): self.assertEqual(lines, ["baz: bletch"]) self.assertEqual(value, ["foo", "bar"]) + def test_multiline_list_carriage_return(self): + y = "foo:\r\n - bar\r\n - baz" + self.assertEqual(monkeyYaml.load(y), yaml.load(y)) + def test_oneline_indented(self): y = " foo: bar\n baz: baf\n" self.assertEqual(monkeyYaml.load(y), yaml.load(y))