diff options
author | Anthon van der Neut <anthon@mnt.org> | 2017-04-04 10:05:01 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2017-04-04 10:05:01 +0200 |
commit | 334c46400c2334b3939c76ab7a7b5d9195b6d131 (patch) | |
tree | 1f92afaffb8689b508234157a179f40df3b84856 /representer.py | |
parent | 106d8df15be91d294b6a6efd4476fdc87c0a9b5d (diff) | |
download | ruamel.yaml-334c46400c2334b3939c76ab7a7b5d9195b6d131.tar.gz |
fix issue #109 and #110
issue 109: None not represented round-trippable at top level, reported by
Andrea Censi
issue 110: .replace() on a ScalarString subclass would return a string instead
of an instance of that subclass, reported by sandres23
Diffstat (limited to 'representer.py')
-rw-r--r-- | representer.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/representer.py b/representer.py index a64d825..5db1d98 100644 --- a/representer.py +++ b/representer.py @@ -644,8 +644,10 @@ class RoundTripRepresenter(SafeRepresenter): def represent_none(self, data): # type: (Any) -> Any - return self.represent_scalar(u'tag:yaml.org,2002:null', - u'') + if len(self.represented_objects) == 0 and not self.serializer.use_explicit_start: + # this will be open ended (although it is not yet) + return self.represent_scalar(u'tag:yaml.org,2002:null', u'null') + return self.represent_scalar(u'tag:yaml.org,2002:null', u'') def represent_preserved_scalarstring(self, data): # type: (Any) -> Any |