summaryrefslogtreecommitdiff
path: root/emitter.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-01-02 20:43:06 +0100
committerAnthon van der Neut <anthon@mnt.org>2019-01-02 20:43:06 +0100
commit2004da336f1736f63062fa70dae374b9ad765917 (patch)
tree01f967e3bfab14d72db2b40bbfcfca782ac2d953 /emitter.py
parentc59babd740f7d6cfd865626f0a0427de8c320987 (diff)
downloadruamel.yaml-2004da336f1736f63062fa70dae374b9ad765917.tar.gz
fix issue with roundtripping mappings keys that are aliases to scalar strings0.15.83
Diffstat (limited to 'emitter.py')
-rw-r--r--emitter.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/emitter.py b/emitter.py
index d4c51f9..99fa6bd 100644
--- a/emitter.py
+++ b/emitter.py
@@ -669,10 +669,15 @@ class Emitter(object):
if not isinstance(
self.event, (SequenceStartEvent, MappingStartEvent)
): # sequence keys
- if self.event.style == '?':
- self.write_indicator(u'?', True, indention=True)
+ try:
+ if self.event.style == '?':
+ self.write_indicator(u'?', True, indention=True)
+ except AttributeError: # aliases have no style
+ pass
self.states.append(self.expect_block_mapping_simple_value)
self.expect_node(mapping=True, simple_key=True)
+ if isinstance(self.event, AliasEvent):
+ self.stream.write(u' ')
else:
self.write_indicator(u'?', True, indention=True)
self.states.append(self.expect_block_mapping_value)