From 3149dd745ed2e38bf23f3db0427db6fbcd05d99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 18 Sep 2014 19:16:27 +0200 Subject: [PATCH] Protect config accessor about missing section issue4189 review7591002 --- trytond/config.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/trytond/config.py b/trytond/config.py index e885e5af4d..728bb127c0 100644 --- a/trytond/config.py +++ b/trytond/config.py @@ -68,26 +68,28 @@ class TrytonConfigParser(ConfigParser.RawConfigParser): def get(self, section, option, default=None): try: return ConfigParser.RawConfigParser.get(self, section, option) - except ConfigParser.NoOptionError: + except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): return default def getint(self, section, option, default=None): try: return ConfigParser.RawConfigParser.getint(self, section, option) - except (ConfigParser.NoOptionError, TypeError): + except (ConfigParser.NoOptionError, ConfigParser.NoSectionError, + TypeError): return default def getfloat(self, section, option, default=None): try: return ConfigParser.RawConfigParser.getfloat(self, section, option) - except (ConfigParser.NoOptionError, TypeError): + except (ConfigParser.NoOptionError, ConfigParser.NoSectionError, + TypeError): return default def getboolean(self, section, option, default=None): try: return ConfigParser.RawConfigParser.getboolean( self, section, option) - except ConfigParser.NoOptionError: + except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): return default config = TrytonConfigParser()