From 6a26a1371cfaa84b6cb664d4b48b102fcb4a7996 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Fri, 14 Dec 2012 11:28:28 +0100 Subject: Make _comment() preserve trailing newlines. --- kconfiglib.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index c6d2a07..fa98855 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -3644,10 +3644,13 @@ def _sep_lines(*args): return "\n".join(args) def _comment(s): - """Returns a new string with "# " inserted before each line in 's'.""" + """Returns a new string with "#" inserted before each line in 's'.""" if not s: return "#" - return "\n".join(["#" + line for line in s.splitlines()]) + res = "".join(["#" + line for line in s.splitlines(True)]) + if s.endswith("\n"): + return res + "#" + return res def _get_lines(filename): """Returns a list of lines from 'filename', joining any line ending in \\ -- cgit v1.2.3