homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ConfigParser.py do not allow leading (and trailing) space in values.
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: duplicate
Dependencies: Superseder: ConfigParser: accept leading whitespace on options+comments
View: 1524825
Assigned To: akuchling Nosy List: akuchling, christian.heimes, draghuram, jonatasoliveira, msuchy, quentin.gallet-gilles, schmir
Priority: low Keywords: easy, patch

Created on 2007年12月31日 15:30 by msuchy, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cfgparser_doublequotes_r61014.patch quentin.gallet-gilles, 2008年02月23日 22:40
Messages (6)
msg59060 - (view) Author: Miroslav Suchy (msuchy) Date: 2007年12月31日 15:30
I have some configuration params with leading space. And program
(getmail4) which use ConfigParser.py. ConfigParser strip all leading
(and trailing) spaces from values. This is very often the most wanted
result. But if I want value with leading space I have no option to put
it there.
Therefore I suggest to optionaly write string value as
key = "value"
This patch will solve it (it is against my OS, sorry no chance to
checkout svn).
--- /usr/lib/python2.4/ConfigParser.py.orig 2007年12月31日
16:04:32.000000000 +0100
+++ /usr/lib/python2.4/ConfigParser.py 2007年12月31日 16:06:50.000000000 +0100
@@ -472,6 +472,7 @@
 if pos != -1 and optval[pos-1].isspace():
 optval = optval[:pos]
 optval = optval.strip()
+ optval = optval.strip('"')
 # allow empty values
 if optval == '""':
 optval = ''
msg59777 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008年01月12日 02:44
Please provide a patch against 2.6 with an unit test and documentation
updates.
msg60186 - (view) Author: Quentin Gallet-Gilles (quentin.gallet-gilles) Date: 2008年01月19日 16:09
Attached patch contain the added behavior, some unit tests to validate
it and updated documentation.
msg62826 - (view) Author: Quentin Gallet-Gilles (quentin.gallet-gilles) Date: 2008年02月23日 22:40
Here's an updated patch, taking in account akuchling and schmir suggestions.
msg66582 - (view) Author: Jonatas Oliveira (jonatasoliveira) Date: 2008年05月10日 20:17
The cfgparser_doublequotes_r61014.patch works for me.
I disagree wrapping a double quoted string with another double quote, it's 
more elegant using single quote like python's string behavior, but I don't 
know if is acceptable for a .ini file.
PS: Like Jeremy Thurgood said in msg66523, this is almost the same of issue 1524825.
msg66591 - (view) Author: Jonatas Oliveira (jonatasoliveira) Date: 2008年05月10日 22:22
Btw, i ran all tests before write "works for me" message.
History
Date User Action Args
2022年04月11日 14:56:29adminsetgithub: 46055
2010年07月10日 05:41:57terry.reedysetstatus: open -> closed
resolution: duplicate
superseder: ConfigParser: accept leading whitespace on options+comments
versions: + Python 3.2, - Python 2.6
2008年05月10日 22:22:13jonatasoliveirasetmessages: + msg66591
2008年05月10日 20:17:40jonatasoliveirasetnosy: + jonatasoliveira
messages: + msg66582
2008年03月25日 16:14:00schmirsetnosy: + schmir
2008年03月25日 14:54:08quentin.gallet-gillessetfiles: - cfgparser_doublequotes.patch
2008年03月06日 19:10:55draghuramsetnosy: + draghuram
2008年02月23日 22:40:21quentin.gallet-gillessetfiles: + cfgparser_doublequotes_r61014.patch
keywords: + patch
messages: + msg62826
2008年02月23日 20:42:22akuchlingsetassignee: akuchling
nosy: + akuchling
2008年01月19日 16:09:00quentin.gallet-gillessetfiles: + cfgparser_doublequotes.patch
nosy: + quentin.gallet-gilles
messages: + msg60186
2008年01月12日 02:44:38christian.heimessetcomponents: + Library (Lib), - Extension Modules
2008年01月12日 02:44:25christian.heimessetpriority: low
keywords: + easy
messages: + msg59777
nosy: + christian.heimes
versions: + Python 2.6, - Python 2.4
2007年12月31日 15:30:01msuchycreate

AltStyle によって変換されたページ (->オリジナル) /