[#2510] Fix config type checking

This commit is contained in:
Calum Lind 2014-09-28 10:07:06 +01:00
parent 3b950094af
commit 11c6e387d5
1 changed files with 5 additions and 5 deletions

View File

@ -179,16 +179,16 @@ what is currently in the config and it could not convert the value
return
# Do not allow the type to change unless it is None
oldtype, newtype = type(self.__config[key]), type(value)
if value is not None and not isinstance(oldtype, type(None)) and not isinstance(oldtype, newtype):
if value is not None and not isinstance(
self.__config[key], type(None)) and not isinstance(self.__config[key], type(value)):
try:
if oldtype == unicode:
oldtype = type(self.__config[key])
if isinstance(self.__config[key], unicode):
value = oldtype(value, "utf8")
else:
value = oldtype(value)
except ValueError:
log.warning("Type '%s' invalid for '%s'", newtype, key)
log.warning("Type '%s' invalid for '%s'", type(value), key)
raise
log.debug("Setting '%s' to %s of %s", key, value, type(value))