set() method of ConfigParser accepts boolean True/False as values at runtime without converting them to strings internally. As a result, getboolean() method reports the following error File "/usr/lib/python2.6/ConfigParser.py", line 350, in getboolean if v.lower() not in self._boolean_states: AttributeError: 'bool' object has no attribute 'lower' since it expects get() method to return strings. (Same problem occurs if other types are used, int/float, etc) Altering set() behavior may be not the best thing to do, I'd rather suggest that getboolean() converts the get() output to string. Of course, the way to avoid this problem is always convert values submitted to set() to strings, but it's a hard-to-catch bug. In my case, I was stuck with problematic configuration when assigning values to wx.CheckBox.GetValue(), which returns boolean.
Would that mean that booleans would be converted to strings on set and converted back on get? Seems wasteful. (I’ve changed the version field for this bug. Its meaning is not “versions this applies to” but “versions that will get a fix”, and 3.2 is the only active branch now. Some bugfixes may still go into 2.7.)
Use SafeConfigParser instead, then you can't make the mistake of passing non-strings to set. We really should update the docs so that ConfigParser is doced only in a 'deprecated' section. But that's a different issue. (Care to open it, merwok? :)
Thanks - gotta rtfm :) On Wed, Jun 2, 2010 at 5:33 PM, R. David Murray <report@bugs.python.org>wrote: > > R. David Murray <rdmurray@bitdance.com> added the comment: > > Use SafeConfigParser instead, then you can't make the mistake of passing > non-strings to set. > > We really should update the docs so that ConfigParser is doced only in a > 'deprecated' section. But that's a different issue. (Care to open it, > merwok? :) > > ---------- > nosy: +r.david.murray > resolution: -> wont fix > stage: -> committed/rejected > status: open -> closed > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue8880> > _______________________________________ >