Issue1524825
Created on 2006-07-18 21:17 by kenlalonde, last changed 2008-05-10 20:23 by jonatasoliveira.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
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) |
|
|
|
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.
|
|
| Date |
User |
Action |
Args |
| 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: feature request versions:
+ Python 2.6, Python 3.0 |
| 2006-07-18 21:17:05 | kenlalonde | create | |
|