diff --git a/sopel/config/__init__.py b/sopel/config/__init__.py index a073101b2e..f930365ce4 100644 --- a/sopel/config/__init__.py +++ b/sopel/config/__init__.py @@ -70,10 +70,8 @@ def homedir(self): # Technically it's the other way around, so we can bootstrap filename # attributes in the core section, but whatever. configured = None - try: + if self.parser.has_option('core', 'homedir'): configured = self.parser.get('core', 'homedir') - except ConfigParser.NoOptionError: - pass if configured: return configured else: diff --git a/sopel/config/types.py b/sopel/config/types.py index 71f3cbf4c3..856d8a6d3a 100644 --- a/sopel/config/types.py +++ b/sopel/config/types.py @@ -143,9 +143,9 @@ def __get__(self, instance, owner=None): # instance here. return self - try: + if instance._parser.has_option(instance._section_name, self.name): value = instance._parser.get(instance._section_name, self.name) - except configparser.NoOptionError: + else: if self.default is not NO_DEFAULT: return self.default raise AttributeError( @@ -290,9 +290,9 @@ def __init__(self, name, relative=True, directory=False, default=None): def __get__(self, instance, owner=None): if instance is None: return self - try: + if instance._parser.has_option(instance._section_name, self.name): value = instance._parser.get(instance._section_name, self.name) - except configparser.NoOptionError: + else: if self.default is not NO_DEFAULT: value = self.default else: