Skip to content

Commit

Permalink
Fix config loading in some edge cases
Browse files Browse the repository at this point in the history
Fixes #999

Usually where try/except wouldn't catch NoOptionError, happens when running tests in specific environments.
  • Loading branch information
maxpowa committed Apr 12, 2016
1 parent 6467386 commit 1d383a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions sopel/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions sopel/config/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1d383a4

Please sign in to comment.