summaryrefslogtreecommitdiff
path: root/comments.py
diff options
context:
space:
mode:
Diffstat (limited to 'comments.py')
-rw-r--r--comments.py11
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: