summaryrefslogtreecommitdiff
path: root/src/config.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-10-31 18:14:56 +0100
committermathieui <mathieui@mathieui.net>2014-10-31 18:14:56 +0100
commitea2b703bfd07d293ba9fdd85ac657275d43da2a7 (patch)
tree426f86216e965b4330911c9ca25b267ade556ce2 /src/config.py
parentf097efd85221b30cd5293b3f7dc52ccbb6fdc05c (diff)
downloadpoezio-ea2b703bfd07d293ba9fdd85ac657275d43da2a7.tar.gz
poezio-ea2b703bfd07d293ba9fdd85ac657275d43da2a7.tar.bz2
poezio-ea2b703bfd07d293ba9fdd85ac657275d43da2a7.tar.xz
poezio-ea2b703bfd07d293ba9fdd85ac657275d43da2a7.zip
Fix the default value of Config.get to None
Might fix some not-yet-seen bugs
Diffstat (limited to 'src/config.py')
-rw-r--r--src/config.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/config.py b/src/config.py
index bd703c5a..1c191eb1 100644
--- a/src/config.py
+++ b/src/config.py
@@ -156,16 +156,19 @@ class Config(RawConfigParser):
if not self.has_section(section):
self.add_section(section)
- def get(self, option, default='', section=DEFSECTION):
+ def get(self, option, default=None, section=DEFSECTION):
"""
get a value from the config but return
a default value if it is not found
The type of default defines the type
returned
"""
- if self.default and not default \
- and self.default.get(section, {}).get(option) is not None:
- default = self.default[section][option]
+ if default is None:
+ if self.default:
+ default = self.default.get(section, {}).get(option)
+ else:
+ default = ''
+
try:
if type(default) == int:
res = self.getint(option, section)
@@ -177,6 +180,7 @@ class Config(RawConfigParser):
res = self.getstr(option, section)
except (NoOptionError, NoSectionError, ValueError, AttributeError):
return default
+
if res is None:
return default
return res