summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-01-22 22:24:56 +0100
committerAnthon van der Neut <anthon@mnt.org>2019-01-22 22:24:56 +0100
commit51d26b878717cf00bee0b961f39e0f14a7e9cdab (patch)
tree7e1b0f4eed20f76c0a95fb7e9ddf096ef25f8cde
parent5028398ac1150a43f4c6eae39b8260ea9cc22a19 (diff)
downloadruamel.yaml-51d26b878717cf00bee0b961f39e0f14a7e9cdab.tar.gz
fix indexing error on empty list for merge-key position0.15.87
-rw-r--r--CHANGES8
-rw-r--r--README.rst8
-rw-r--r--__init__.py4
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--main.py2
-rw-r--r--representer.py5
6 files changed, 22 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index d56f30e..574758a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+[0, 15, 87]: 2019-01-22
+ - fix problem with empty lists and the code to reinsert merge keys (reported via email
+ by Zaloo)
+
+[0, 15, 87]: 2019-01-22
+ - fix problem with empty lists and the code to reinsert merge keys (reported via email
+ by Zaloo)
+
[0, 15, 86]: 2019-01-16
- reinsert merge key in its old position (reported by grumbler on
<Stackoverflow <https://stackoverflow.com/a/54206512/1307905>`__)
diff --git a/README.rst b/README.rst
index 809dd10..b62889d 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.86
-:updated: 2019-01-16
+:version: 0.15.87
+:updated: 2019-01-22
: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.87 (2019-01-22):
+ - fix problem with empty lists and the code to reinsert merge keys (reported via email
+ by Zaloo)
+
0.15.86 (2019-01-16):
- reinsert merge key in its old position (reported by grumbler on
<Stackoverflow <https://stackoverflow.com/a/54206512/1307905>`__)
diff --git a/__init__.py b/__init__.py
index 1cb3f30..f03f94d 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, 86),
- __version__='0.15.86',
+ version_info=(0, 15, 87),
+ __version__='0.15.87',
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 23fc356..a142d11 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.86</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.86</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.87</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.87</text></g> </svg>
diff --git a/main.py b/main.py
index f06c52e..184c7ad 100644
--- a/main.py
+++ b/main.py
@@ -324,7 +324,7 @@ class YAML(object):
"""
if not hasattr(stream, 'read') and hasattr(stream, 'open'):
# pathlib.Path() instance
- with stream.open('r') as fp: # type: ignore
+ with stream.open('rb') as fp: # type: ignore
return self.load(fp)
constructor, parser = self.get_constructor_parser(stream)
try:
diff --git a/representer.py b/representer.py
index 7b2f007..859887c 100644
--- a/representer.py
+++ b/representer.py
@@ -1002,7 +1002,10 @@ class RoundTripRepresenter(SafeRepresenter):
except AttributeError:
item_comments = {}
merge_list = [m[1] for m in getattr(mapping, merge_attrib, [])]
- merge_pos = getattr(mapping, merge_attrib, [[0]])[0][0]
+ try:
+ merge_pos = getattr(mapping, merge_attrib, [[0]])[0][0]
+ except IndexError:
+ merge_pos = 0
item_count = 0
if bool(merge_list):
items = mapping.non_merged_items()