diff --git a/lib/yaml/scanner.py b/lib/yaml/scanner.py index de925b07..4cea1a2e 100644 --- a/lib/yaml/scanner.py +++ b/lib/yaml/scanner.py @@ -1306,7 +1306,7 @@ def scan_plain(self): if not spaces or self.peek() == '#' \ or (not self.flow_level and self.column < indent): break - return ScalarToken(''.join(chunks), True, start_mark, end_mark) + return ScalarToken(''.join(chunks), True, start_mark, end_mark, style='') def scan_plain_spaces(self, indent, start_mark): # See the specification for details. diff --git a/tests/test_scan.py b/tests/test_scan.py new file mode 100644 index 00000000..fa65610b --- /dev/null +++ b/tests/test_scan.py @@ -0,0 +1,18 @@ +import pytest + +import yaml +from yaml.tokens import StreamStartToken, ScalarToken, StreamEndToken + + +_loaders = (yaml.SafeLoader,) +if yaml.__with_libyaml__: + _loaders += (yaml.CSafeLoader,) + + +@pytest.mark.parametrize('loader_cls', _loaders) +def test_scan_produces_empty_string_style_for_scalar_node(loader_cls): + start, scalar, end = yaml.scan('example', Loader=loader_cls) + assert isinstance(start, StreamStartToken) + assert isinstance(scalar, ScalarToken) + assert scalar.style == '' + assert isinstance(end, StreamEndToken)