Convert the value in proper format, as we may only get string values

for integer and numeric type.
This commit is contained in:
Ashesh Vashi 2016-03-24 14:29:44 +05:30
parent 242d5f47f6
commit 067c269fc8

View File

@ -146,9 +146,11 @@ class _Preference(object):
if type(value) != bool: if type(value) != bool:
return False, gettext("Invalid value for boolean type!") return False, gettext("Invalid value for boolean type!")
elif self._type == 'integer': elif self._type == 'integer':
value = int(value)
if type(value) != int: if type(value) != int:
return False, gettext("Invalid value for integer type!") return False, gettext("Invalid value for integer type!")
elif self._type == 'numeric': elif self._type == 'numeric':
value = float(value)
t = type(value) t = type(value)
if t != float and t != int and t != decimal.Decimal: if t != float and t != int and t != decimal.Decimal:
return False, gettext("Invalid value for numeric type!") return False, gettext("Invalid value for numeric type!")