[ python-Bugs-1603688 ] SaveConfigParser.write() doesn't quote %-Sign
SourceForge.net
noreply at sourceforge.net
Tue Jan 16 21:50:44 CET 2007
Bugs item #1603688, was opened at 2006-11-27 12:15
Message generated for change (Comment added) made by gbrandl
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1603688&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
>Status: Closed
>Resolution: Duplicate
Priority: 5
Private: No
Submitted By: Rebecca Breu (rbreu)
Assigned to: Nobody/Anonymous (nobody)
Summary: SaveConfigParser.write() doesn't quote %-Sign
Initial Comment:
>>> parser = ConfigParser.SafeConfigParser()
>>> parser.add_section("test")
>>> parser.set("test", "foo", "bar%bar")
>>> parser.write(open("test.config", "w"))
>>> parser2 = ConfigParser.SafeConfigParser()
>>> parser2.readfp(open("test.config"))
>>> parser.get("test", "foo")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/ConfigParser.py", line 525, in get
return self._interpolate(section, option, value, d)
File "/usr/lib/python2.4/ConfigParser.py", line 593, in _interpolate
self._interpolate_some(option, L, rawval, section, vars, 1)
File "/usr/lib/python2.4/ConfigParser.py", line 634, in _interpolate_some
"'%%' must be followed by '%%' or '(', found: %r" % (rest,))
ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%bar'
Problem: SaveConfigParser saves the string "bar%bar" as is and not as "bar%%bar".
----------------------------------------------------------------------
>Comment By: Georg Brandl (gbrandl)
Date: 2007-01-16 20:50
Message:
Logged In: YES
user_id=849994
Originator: NO
Closing this as a duplicate.
----------------------------------------------------------------------
Comment By: Mark Roberts (mark-roberts)
Date: 2007-01-15 07:45
Message:
Logged In: YES
user_id=1591633
Originator: NO
Initially, I believed ValueError was the appropriate way to go with this.
However, when I thought about how I use ConfigParser, I realized that it
would be far nicer if it simply worked.
See the patches in 1635639.
http://sourceforge.net/tracker/index.php?func=detail&aid=1635639&group_id=5470&atid=105470
Good catch on this. I haven't caught it and I've been using ConfigParser
for a while now.
----------------------------------------------------------------------
Comment By: Mark Roberts (mark-roberts)
Date: 2007-01-15 02:33
Message:
Logged In: YES
user_id=1591633
Originator: NO
I'm not sure that automagically changing their input is such a great idea.
I'm -0 for automagically changing their input, but +1 for raising
ValueError when the input contains a string that can't be properly
interpolated. I've implemented the patch both ways. Anyone else have an
opinion about this?
Examples of such malformatted strings include bar%bar and bar%.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1603688&group_id=5470
More information about the Python-bugs-list
mailing list