[issue1524825] ConfigParser: accept leading whitespace on options+comments

Quentin Gallet-Gilles report at bugs.python.org
Sun Feb 24 01:36:52 CET 2008


Quentin Gallet-Gilles added the comment:

I tried to come up with a patch, but the issue isn't as easy as it
seems, the proposed change is too simplistic. Leading spaces in a line
is already used for one purpose : continuations of a previous line. For
instance :
option = value
  continued here
gives "option" as key and "value\n  continued here" as value.

The proposal conflicts with this behavior, since having :
option1 = value1
  option2 = value2
creates only one key-value pair "option1":"value1\n  option2=value2"

Adding blank lines doesn't solve the issue. The only case when it's
treated correctly is when the options is the first one of a
section/file: there's no continuation since there's no previous option
defined.

One solution could be to check for the presence of a delimiter (colon or
equals sign) and not treat it as a continuation if that's the case, but
that could potentially break existing configurations files, since
nothing forbids you from using delimiters in the values.

Any opinion ?

(By the way, the leading whitespaces for comments isn't affected by all
this, the implementation is simple)

----------
nosy: +quentin.gallet-gilles

_____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1524825>
_____________________________________


More information about the Python-bugs-list mailing list