[New-bugs-announce] [issue10387] ConfigParser's getboolean method is broken
Felix Laurie von Massenbach
report at bugs.python.org
Thu Nov 11 13:06:24 CET 2010
New submission from Felix Laurie von Massenbach <fantasizer at gmail.com>:
If the config file has a boolean formatted as either True or False, python raises an attribute error when doing str.lower() on it. In my code I've worked around this in the following way:
class MyConfigParser(ConfigParser.RawConfigParser):
def getboolean(self, section, option):
result = self.get(section, option)
try:
trues = ["1", "yes", "true", "on"]
falses = ["0", "no", "false", "off"]
if result in trues:
return True
if result in falses:
return False
except AttributeError as err:
if str(err) == "\'bool\' object has no attribute \'lower\'":
return result
raise err
Felix
(p.s. first bug report, sorry if it's a bit of a mess...)
----------
components: Extension Modules
messages: 120943
nosy: Felix.Laurie.von.Massenbach
priority: normal
severity: normal
status: open
title: ConfigParser's getboolean method is broken
type: crash
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10387>
_______________________________________
More information about the New-bugs-announce
mailing list