osx_defaults: Fix boolean value parsing

Values for boolean types were being unconditionally treated as strings
(by calling `.lower()`), thus breaking value parsing for actual boolean
and integer objects.

It looks like the bug was introduced in:

- 130bd670d8

Fixes #709.
reviewable/pr18780/r1
Tom X. Tobin 9 years ago
parent e5982ba5e3
commit 4c4a58e77b

@ -124,9 +124,11 @@ class OSXDefaults(object):
if type == "string": if type == "string":
return str(value) return str(value)
elif type in ["bool", "boolean"]: elif type in ["bool", "boolean"]:
if value.lower() in [True, 1, "true", "1", "yes"]: if isinstance(value, basestring):
value = value.lower()
if value in [True, 1, "true", "1", "yes"]:
return True return True
elif value.lower() in [False, 0, "false", "0", "no"]: elif value in [False, 0, "false", "0", "no"]:
return False return False
raise OSXDefaultsException("Invalid boolean value: {0}".format(repr(value))) raise OSXDefaultsException("Invalid boolean value: {0}".format(repr(value)))
elif type == "date": elif type == "date":

Loading…
Cancel
Save