diff options
author | Anthon van der Neut <anthon@mnt.org> | 2021-08-28 20:59:55 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2021-08-28 20:59:55 +0200 |
commit | a67ac7764d4d599d4b78addcf4126fc837292705 (patch) | |
tree | 76650f45427e5f54544f27e03c92c0cbc439209d /comments.py | |
parent | e9758fbad489545478ecb9901c27d0627ca504fc (diff) | |
download | ruamel.yaml-a67ac7764d4d599d4b78addcf4126fc837292705.tar.gz |
handle 397 with newline0.17.16
Diffstat (limited to 'comments.py')
-rw-r--r-- | comments.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/comments.py b/comments.py index 6d2eb6b..053b4f1 100644 --- a/comments.py +++ b/comments.py @@ -391,13 +391,14 @@ class CommentedBase: after = after[:-1] # strip final newline if there start_mark = CommentMark(indent) c = self.ca.items.setdefault(key, [None, [], None, None]) - if before == '\n': - c[1].append(comment_token("", start_mark)) - elif before: + if before is not None: if c[1] is None: c[1] = [] - for com in before.split('\n'): - c[1].append(comment_token(com, start_mark)) + if before == '\n': + c[1].append(comment_token("", start_mark)) + else: + for com in before.split('\n'): + c[1].append(comment_token(com, start_mark)) if after: start_mark = CommentMark(after_indent) if c[3] is None: |