summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-04-23 08:33:36 +0200
committerAnthon van der Neut <anthon@mnt.org>2019-04-23 08:33:36 +0200
commita648518ebda2003a61649c86938dd3846810a9b0 (patch)
tree18f7d93d37e50073fa3eb12f4af9138761f5228f
parent0d1300c8b70de0ad2990b3f95629305dee870f0a (diff)
downloadruamel.yaml-a648518ebda2003a61649c86938dd3846810a9b0.tar.gz
add line-break to EOF comment without one0.15.94
fixes issue #286 *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
-rw-r--r--CHANGES5
-rw-r--r--README.rst9
-rw-r--r--__init__.py4
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--_test/test_issues.py16
-rw-r--r--scanner.py4
6 files changed, 35 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index 31cd652..cbbbf1d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+[0, 15, 94]: 2019-04-23
+ - fix missing line-break after end-of-file comments not ending in
+ line-break (reported by `Philip Thompson
+ <https://bitbucket.org/%7Be42ba205-0876-4151-bcbe-ccaea5bd13ce%7D/>`__)
+
[0, 15, 93]: 2019-04-21
- fix failure to parse empty implicit flow mapping key
- in YAML 1.1 plains scalars `y`, 'n', `Y`, and 'N' are now
diff --git a/README.rst b/README.rst
index 1be8227..368f536 100644
--- a/README.rst
+++ b/README.rst
@@ -4,8 +4,8 @@ ruamel.yaml
``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python.
-:version: 0.15.93
-:updated: 2019-04-21
+:version: 0.15.94
+:updated: 2019-04-23
:documentation: http://yaml.readthedocs.io
:repository: https://bitbucket.org/ruamel/
:pypi: https://pypi.org/project/ruamel.yaml/
@@ -54,6 +54,11 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key (with empty line)
+0.15.94 (2019-04-23):
+ - fix missing line-break after end-of-file comments not ending in
+ line-break (reported by `Philip Thompson
+ <https://bitbucket.org/%7Be42ba205-0876-4151-bcbe-ccaea5bd13ce%7D/>`__)
+
0.15.93 (2019-04-21):
- fix failure to parse empty implicit flow mapping key
- in YAML 1.1 plains scalars `y`, 'n', `Y`, and 'N' are now
diff --git a/__init__.py b/__init__.py
index 6874999..c7aa6c8 100644
--- a/__init__.py
+++ b/__init__.py
@@ -7,8 +7,8 @@ if False: # MYPY
_package_data = dict(
full_package_name='ruamel.yaml',
- version_info=(0, 15, 93),
- __version__='0.15.93',
+ version_info=(0, 15, 94),
+ __version__='0.15.94',
author='Anthon van der Neut',
author_email='a.van.der.neut@ruamel.eu',
description='ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order', # NOQA
diff --git a/_doc/_static/pypi.svg b/_doc/_static/pypi.svg
index e0ca818..10d8154 100644
--- a/_doc/_static/pypi.svg
+++ b/_doc/_static/pypi.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.93</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.93</text></g> </svg>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.94</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.94</text></g> </svg>
diff --git a/_test/test_issues.py b/_test/test_issues.py
index 6392ebd..dd534ca 100644
--- a/_test/test_issues.py
+++ b/_test/test_issues.py
@@ -648,6 +648,22 @@ class TestIssues:
assert not a[1]
assert not a[3]
+ def test_issue_286(self):
+ from ruamel.yaml import YAML
+ from ruamel.yaml.compat import StringIO
+
+ yaml = YAML()
+ inp = dedent("""\
+ parent_key:
+ - sub_key: sub_value
+
+ # xxx""")
+ a = yaml.load(inp)
+ a['new_key'] = 'new_value'
+ buf = StringIO()
+ yaml.dump(a, buf)
+ assert buf.getvalue().endswith('xxx\nnew_key: new_value\n')
+
# @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError)
# def test_issue_ xxx(self):
# inp = """
diff --git a/scanner.py b/scanner.py
index 1967a56..46247f1 100644
--- a/scanner.py
+++ b/scanner.py
@@ -1877,6 +1877,10 @@ class RoundTripScanner(Scanner):
while ch not in _THE_END:
ch = srp()
if ch == '\0': # don't gobble the end-of-stream character
+ # but add an explicit newline as "YAML processors should terminate
+ # the stream with an explicit line break
+ # https://yaml.org/spec/1.2/spec.html#id2780069
+ comment += '\n'
break
comment += ch
srf()