msg50719 - (view) |
Author: Ken Lalonde (kenlalonde) |
Date: 2006-07-18 21:17 |
ConfigParser considers leading white space before options and comments to be syntax errors, which is a bit harsh, and limits the utility of the module when parsing files originally written for other programs, such as Samba's smb.conf. The attached patch ignores leading white space on options, and skips comments with leading w.s. |
|
|
msg50720 - (view) |
Author: Chad Whitacre (whit537) |
Date: 2006-07-31 20:53 |
Logged In: YES user_id=340931 Thanks for the patch Ken! This change sounds reasonable and low-risk. However, some patch suggestions: 1. Diff against HEAD of trunk/ from svn, not your platform's python installation 2. Add some tests in Lib/test/test_cfgparser.py (this will be in a source distribution from svn, but not in your platform's binary distribution) 3. Update the doc in Doc/lib/libcfgparser.tex (again, this will be in a source dist) FWIW, these are mentioned in the (admittedly somewhat obtuse) patch guidelines: http://www.python.org/dev/patches/ |
|
|
msg62856 - (view) |
Author: Quentin Gallet-Gilles (quentin.gallet-gilles) |
Date: 2008-02-24 00:36 |
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) |
|
|
msg62993 - (view) |
Author: Ken Lalonde (kenlalonde) |
Date: 2008-02-25 19:26 |
Quentin: I didn't appreciate the line-continuation issue. Breaking existing code is out of the question, so I'd like to retract that part of the patch. |
|
|
msg63047 - (view) |
Author: Quentin Gallet-Gilles (quentin.gallet-gilles) |
Date: 2008-02-26 15:31 |
Okay, I'll upload a patch with unit tests and doc changes for the comment part in the next few days. |
|
|
msg64482 - (view) |
Author: Quentin Gallet-Gilles (quentin.gallet-gilles) |
Date: 2008-03-25 13:59 |
Didn't think "a few days" would translate into a month. My bad! Anyway, here's the promised patch. |
|
|
msg66523 - (view) |
Author: Jeremy Thurgood (jerith) |
Date: 2008-05-10 14:01 |
This looks very much like a duplicate of issue 1714. Perhaps the two should be merged? |
|
|
msg66583 - (view) |
Author: Jonatas Oliveira (jonatasoliveira) |
Date: 2008-05-10 20:23 |
The patch cfgparser_comments.patch works for me. I agree with Jeremy Thurgood about the issue 1714. |
|
|
msg109818 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2010-07-10 05:41 |
I closed #1714 as a duplicate of this. It also has a patch attached. |
|
|
msg111659 - (view) |
Author: Ćukasz Langa (lukasz.langa) *  |
Date: 2010-07-26 18:11 |
Implemented as part of since it touches the same code. Moreover, this issue mentions Samba config parsing in the original comment () which was not doable without the changes introduced by . So I would supersede this issue with . One way or the other, they both fly or both go. Michael, can you close this as superseded? |
|
|