Issue1524825
Created on 2006-07-18 21:17 by kenlalonde, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| patch.txt | kenlalonde, 2006-07-18 21:17 | Patch to ConfigParser.py, current SVN | ||
| cfgparser_comments.patch | quentin.gallet-gilles, 2008-03-25 13:59 | Patch against trunk (r61890) | ||
| Messages (10) | |||
|---|---|---|---|
| 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 issue1682942 since it touches the same code. Moreover, this issue mentions Samba config parsing in the original comment (msg50719) which was not doable without the changes introduced by issue1682942. So I would supersede this issue with issue1682942. One way or the other, they both fly or both go. Michael, can you close this as superseded? |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:18 | admin | set | github: 43689 |
| 2010-07-26 20:17:23 | terry.reedy | set | superseder: ConfigParser support for alt delimiters |
| 2010-07-26 18:13:24 | michael.foord | set | status: open -> closed resolution: duplicate stage: resolved |
| 2010-07-26 18:11:45 | lukasz.langa | set | nosy:
+ michael.foord, lukasz.langa messages: + msg111659 |
| 2010-07-10 05:41:57 | terry.reedy | link | issue1714 superseder |
| 2010-07-10 05:41:44 | terry.reedy | set | nosy:
+ christian.heimes, schmir, akuchling, msuchy, terry.reedy messages:
+ msg109818 |
| 2008-05-10 20:23:28 | jonatasoliveira | set | nosy:
+ jonatasoliveira messages: + msg66583 |
| 2008-05-10 14:01:11 | jerith | set | nosy:
+ jerith messages: + msg66523 |
| 2008-03-25 13:59:55 | quentin.gallet-gilles | set | files:
+ cfgparser_comments.patch keywords: + patch messages: + msg64482 |
| 2008-03-06 19:11:11 | draghuram | set | nosy: + draghuram |
| 2008-02-26 15:31:04 | quentin.gallet-gilles | set | messages: + msg63047 |
| 2008-02-25 19:26:09 | kenlalonde | set | messages: + msg62993 |
| 2008-02-24 00:36:51 | quentin.gallet-gilles | set | nosy:
+ quentin.gallet-gilles messages: + msg62856 |
| 2008-02-23 22:05:03 | facundobatista | set | keywords: + easy, - patch |
| 2008-02-23 22:03:58 | georg.brandl | set | type: enhancement versions: + Python 2.6, Python 3.0 |
| 2006-07-18 21:17:05 | kenlalonde | create | |
