Fix for r83202: improve the handling of empty lines.
This commit is contained in:
parent
c62a704189
commit
f206d0e393
@ -558,7 +558,7 @@ class RawConfigParser:
|
|||||||
indent_level = 0
|
indent_level = 0
|
||||||
e = None # None, or an exception
|
e = None # None, or an exception
|
||||||
for lineno, line in enumerate(fp, start=1):
|
for lineno, line in enumerate(fp, start=1):
|
||||||
# strip prefix-only comments
|
# strip full line comments
|
||||||
comment_start = None
|
comment_start = None
|
||||||
for prefix in self._startonly_comment_prefixes:
|
for prefix in self._startonly_comment_prefixes:
|
||||||
if line.strip().startswith(prefix):
|
if line.strip().startswith(prefix):
|
||||||
@ -572,11 +572,14 @@ class RawConfigParser:
|
|||||||
break
|
break
|
||||||
value = line[:comment_start].strip()
|
value = line[:comment_start].strip()
|
||||||
if not value:
|
if not value:
|
||||||
if self._empty_lines_in_values and comment_start is None:
|
if self._empty_lines_in_values:
|
||||||
# add empty line to the value, but only if there was no
|
# add empty line to the value, but only if there was no
|
||||||
# comment on the line
|
# comment on the line
|
||||||
if cursect is not None and optname:
|
if (comment_start is None and
|
||||||
cursect[optname].append('\n')
|
cursect is not None and
|
||||||
|
optname and
|
||||||
|
cursect[optname] is not None):
|
||||||
|
cursect[optname].append('') # newlines added at join
|
||||||
else:
|
else:
|
||||||
# empty line marks end of value
|
# empty line marks end of value
|
||||||
indent_level = sys.maxsize
|
indent_level = sys.maxsize
|
||||||
@ -643,9 +646,7 @@ class RawConfigParser:
|
|||||||
for options in all_sections:
|
for options in all_sections:
|
||||||
for name, val in options.items():
|
for name, val in options.items():
|
||||||
if isinstance(val, list):
|
if isinstance(val, list):
|
||||||
if val[-1] == '\n':
|
options[name] = '\n'.join(val).rstrip()
|
||||||
val = val[:-1]
|
|
||||||
options[name] = '\n'.join(val)
|
|
||||||
|
|
||||||
def _handle_error(self, exc, fpname, lineno, line):
|
def _handle_error(self, exc, fpname, lineno, line):
|
||||||
if not exc:
|
if not exc:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user