[issue8880] ConfigParser.set does not convert non-string values

Edwin Pozharski report at bugs.python.org
Wed Jun 2 23:01:38 CEST 2010


New submission from Edwin Pozharski <pozharski at gmail.com>:

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.

----------
messages: 106912
nosy: Edwin.Pozharski
priority: normal
severity: normal
status: open
title: ConfigParser.set does not convert non-string values
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8880>
_______________________________________


More information about the Python-bugs-list mailing list