From 11c6e387d5288cb4dd766c8eb5494acc8c3ce2d5 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 28 Sep 2014 10:07:06 +0100 Subject: [PATCH] [#2510] Fix config type checking --- deluge/config.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/deluge/config.py b/deluge/config.py index a59f922d3..f38b45151 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -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))