This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Felix.Laurie.von.Massenbach
Recipients Felix.Laurie.von.Massenbach
Date 2010-11-11.12:06:20
SpamBayes Score 2.5897552e-06
Marked as misclassified No
Message-id <1289477184.84.0.648837356177.issue10387@psf.upfronthosting.co.za>
In-reply-to
Content
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...)
History
Date User Action Args
2010-11-11 12:06:24Felix.Laurie.von.Massenbachsetrecipients: + Felix.Laurie.von.Massenbach
2010-11-11 12:06:24Felix.Laurie.von.Massenbachsetmessageid: <1289477184.84.0.648837356177.issue10387@psf.upfronthosting.co.za>
2010-11-11 12:06:20Felix.Laurie.von.Massenbachlinkissue10387 messages
2010-11-11 12:06:20Felix.Laurie.von.Massenbachcreate