New submission from Felix Laurie von Massenbach <[email protected]>:
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 <[email protected]>
<http://bugs.python.org/issue10387>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com