1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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:

- 130bd670d82cc55fa321021e819838e07ff10c08

Fixes #709.
This commit is contained in:
Tom X. Tobin 2016-01-14 12:44:05 -05:00 committed by Matt Clay
parent 9d355fb5af
commit 1223143ebe

View file

@ -124,9 +124,11 @@ class OSXDefaults(object):
if type == "string":
return str(value)
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
elif value.lower() in [False, 0, "false", "0", "no"]:
elif value in [False, 0, "false", "0", "no"]:
return False
raise OSXDefaultsException("Invalid boolean value: {0}".format(repr(value)))
elif type == "date":