summaryrefslogtreecommitdiff
path: root/representer.py
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 /representer.py
parent5028398ac1150a43f4c6eae39b8260ea9cc22a19 (diff)
downloadruamel.yaml-51d26b878717cf00bee0b961f39e0f14a7e9cdab.tar.gz
fix indexing error on empty list for merge-key position0.15.87
Diffstat (limited to 'representer.py')
-rw-r--r--representer.py5
1 files changed, 4 insertions, 1 deletions
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()