SafeConfigParse r is supposed to be safer than ConfigParser, but calling
set with a string value containing '%' generates exceptions when you
get() it back.
Python 2.5.1 (r251:54863, Apr 25 2007, 21:31:46)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named configparser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/ConfigParser.py ", line 525, in get
return self._interpola te(section, option, value, d)
File "/usr/lib/python2.5/ConfigParser.py ", line 593, in _interpolate
self._interpola te_some(option, L, rawval, section, vars, 1)
File "/usr/lib/python2.5/ConfigParser.py ", line 634, in _interpolate_so me
"'%%' must be followed by '%%' or '(', found: %r" % (rest,))
ConfigParser.In terpolationSynt axError: '%' must be followed by '%' or
'(', found: '%there'
ConfigParser does not do this:
'hi%there'
Should SafeConfigParse r.set() be escaping automatically?
Hamish
set with a string value containing '%' generates exceptions when you
get() it back.
Python 2.5.1 (r251:54863, Apr 25 2007, 21:31:46)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>import configparser
File "<stdin>", line 1, in <module>
ImportError: No module named configparser
>>import ConfigParser
>>>
>>x=ConfigParse r.SafeConfigPar ser()
>>x.add_section ('test')
>>x.set('test ', 'a', 'hi%there')
>>x.get('test ', 'a')
>>>
>>x=ConfigParse r.SafeConfigPar ser()
>>x.add_section ('test')
>>x.set('test ', 'a', 'hi%there')
>>x.get('test ', 'a')
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/ConfigParser.py ", line 525, in get
return self._interpola te(section, option, value, d)
File "/usr/lib/python2.5/ConfigParser.py ", line 593, in _interpolate
self._interpola te_some(option, L, rawval, section, vars, 1)
File "/usr/lib/python2.5/ConfigParser.py ", line 634, in _interpolate_so me
"'%%' must be followed by '%%' or '(', found: %r" % (rest,))
ConfigParser.In terpolationSynt axError: '%' must be followed by '%' or
'(', found: '%there'
ConfigParser does not do this:
>>y=ConfigParse r.ConfigParser( )
>>y.add_section ('test')
>>y.set('test ', 'a', 'hi%there')
>>y.get('test ', 'a')
>>y.add_section ('test')
>>y.set('test ', 'a', 'hi%there')
>>y.get('test ', 'a')
Should SafeConfigParse r.set() be escaping automatically?
Hamish
Comment