[issue1714] ConfigParser.py do not allow leading (and trailing) space in values.

Miroslav Suchy report at bugs.python.org
Mon Dec 31 16:30:02 CET 2007


New submission from Miroslav Suchy:

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 = ''

----------
components: Extension Modules
messages: 59060
nosy: msuchy
severity: normal
status: open
title: ConfigParser.py do not allow leading (and trailing) space in values.
type: behavior
versions: Python 2.4

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1714>
__________________________________


More information about the Python-bugs-list mailing list