summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rw-r--r--README.rst10
-rw-r--r--__init__.py4
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--emitter.py13
-rw-r--r--nodes.py7
-rw-r--r--representer.py6
-rw-r--r--scalarstring.py2
8 files changed, 32 insertions, 16 deletions
diff --git a/CHANGES b/CHANGES
index dad1a5c..9d17020 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+[0, 15, 80]: 2018-11-26
+ - fix issue emitting BEL character when round-tripping invalid folded input
+ (reported by Isaac on `StackOverflow <https://stackoverflow.com/a/53471217/1307905>`__)
+
[0, 15, 79]: 2018-11-21
- fix issue with anchors nested deeper than alias (reported by gaFF on
`StackOverflow <https://stackoverflow.com/a/53397781/1307905>`__)
diff --git a/README.rst b/README.rst
index 69eed0c..61f7b52 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.79
-:updated: 2018-11-21
+:version: 0.15.80
+:updated: 2018-11-26
:documentation: http://yaml.readthedocs.io
:repository: https://bitbucket.org/ruamel/
:pypi: https://pypi.org/project/ruamel.yaml/
@@ -54,6 +54,10 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key (with empty line)
+0.15.80 (2018-11-26):
+ - fix issue emitting BEL character when round-tripping invalid folded input
+ (reported by Isaac on `StackOverflow <https://stackoverflow.com/a/53471217/1307905>`__)
+
0.15.79 (2018-11-21):
- fix issue with anchors nested deeper than alias (reported by gaFF on
`StackOverflow <https://stackoverflow.com/a/53397781/1307905>`__)
@@ -145,7 +149,7 @@ ChangeLog
0.15.64 (2018-08-30):
- support round-trip of tagged sequences: ``!Arg [a, {b: 1}]``
- - single entry mappings in flow sequences now written by default without quotes
+ - single entry mappings in flow sequences now written by default without braces,
set ``yaml.brace_single_entry_mapping_in_flow_sequence=True`` to force
getting ``[a, {b: 1}, {c: {d: 2}}]`` instead of the default ``[a, b: 1, c: {d: 2}]``
- fix issue when roundtripping floats starting with a dot such as ``.5``
diff --git a/__init__.py b/__init__.py
index 9988df7..8033a8b 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, 79),
- __version__='0.15.79',
+ version_info=(0, 15, 80),
+ __version__='0.15.80',
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 e9d13c5..7c76e41 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.79</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.79</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.80</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.80</text></g> </svg>
diff --git a/emitter.py b/emitter.py
index c410f2e..61ca269 100644
--- a/emitter.py
+++ b/emitter.py
@@ -156,8 +156,8 @@ class Emitter(object):
self.column = 0
self.whitespace = True
self.indention = True
- self.compact_seq_seq = True # dash after dash
- self.compact_seq_map = True # key after dash
+ self.compact_seq_seq = True # dash after dash
+ self.compact_seq_map = True # key after dash
# self.compact_ms = False # dash after key, only when excplicit key with ?
self.no_newline = None # type: Optional[bool] # set if directly after `- `
@@ -1463,9 +1463,12 @@ class Emitter(object):
data = data.encode(self.encoding)
self.stream.write(data)
if ch == u'\a':
- self.write_line_break()
- self.write_indent()
- end += 2 # \a and the space that is inserted on the fold
+ if end < (len(text) - 1) and not text[end + 2].isspace():
+ self.write_line_break()
+ self.write_indent()
+ end += 2 # \a and the space that is inserted on the fold
+ else:
+ raise EmitterError('unexcpected fold indicator \\a before space')
if ch is None:
self.write_line_break()
start = end
diff --git a/nodes.py b/nodes.py
index d99e909..da86e9c 100644
--- a/nodes.py
+++ b/nodes.py
@@ -78,15 +78,16 @@ class ScalarNode(Node):
__slots__ = ('style',)
id = 'scalar'
- def __init__(self, tag, value, start_mark=None, end_mark=None, style=None, comment=None,
- anchor=None):
+ def __init__(
+ self, tag, value, start_mark=None, end_mark=None, style=None, comment=None, anchor=None
+ ):
# type: (Any, Any, Any, Any, Any, Any, Any) -> None
Node.__init__(self, tag, value, start_mark, end_mark, comment=comment, anchor=anchor)
self.style = style
class CollectionNode(Node):
- __slots__ = ('flow_style', )
+ __slots__ = ('flow_style',)
def __init__(
self,
diff --git a/representer.py b/representer.py
index 143b7d5..7ce810e 100644
--- a/representer.py
+++ b/representer.py
@@ -691,7 +691,11 @@ class RoundTripRepresenter(SafeRepresenter):
tag = None
style = '>'
for fold_pos in reversed(getattr(data, 'fold_pos', [])):
- if data[fold_pos] == ' ':
+ if (
+ data[fold_pos] == ' '
+ and (fold_pos > 0 and not data[fold_pos - 1].isspace())
+ and (fold_pos < len(data) and not data[fold_pos + 1].isspace())
+ ):
data = data[:fold_pos] + '\a' + data[fold_pos:]
if PY2 and not isinstance(data, unicode):
data = unicode(data, 'ascii')
diff --git a/scalarstring.py b/scalarstring.py
index c7b1a78..0566164 100644
--- a/scalarstring.py
+++ b/scalarstring.py
@@ -21,7 +21,7 @@ __all__ = [
class ScalarString(text_type):
- __slots__ = (Anchor.attrib)
+ __slots__ = Anchor.attrib
def __new__(cls, *args, **kw):
# type: (Any, Any) -> Any