Bugs item #1603688, was opened at 2006-11-27 06:15
Message generated for change (Comment added) made by mark-roberts
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: Open
Resolution: None
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: Mark Roberts (mark-roberts)
Date: 2007-01-15 01: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-14 20: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
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to