Comments
Patch
@@ -501,7 +501,7 @@ class ui(object):
% (section, name, v))
return b
- def configwith(self, convert, section, name, default=None,
+ def configwith(self, convert, section, name, default=_unset,
desc=None, untrusted=False):
"""parse a configuration element with a conversion function
@@ -513,7 +513,7 @@ class ui(object):
>>> u.configwith(float, s, 'float2')
-4.25
>>> u.configwith(float, s, 'unknown', 7)
- 7
+ 7.0
>>> u.setconfig(s, 'invalid', 'somevalue')
>>> u.configwith(float, s, 'invalid')
Traceback (most recent call last):
@@ -525,9 +525,9 @@ class ui(object):
ConfigError: foo.invalid is not a valid womble ('somevalue')
"""
- v = self.config(section, name, None, untrusted)
+ v = self.config(section, name, default, untrusted)
if v is None:
- return default
+ return v # do not attempt to convert None
try:
return convert(v)
except (ValueError, error.ParseError):