From ad569fc0d92a0e588ba2a5d9db3cb33017474b80 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sun, 21 Feb 2010 12:59:34 +0000 Subject: [PATCH] Allows unicode strings in config .ini files svn: r14424 --- src/gen/utils/configmanager.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gen/utils/configmanager.py b/src/gen/utils/configmanager.py index a1febbc7b..b73d5c1fd 100644 --- a/src/gen/utils/configmanager.py +++ b/src/gen/utils/configmanager.py @@ -279,7 +279,10 @@ class ConfigManager(object): ####################### Now, let's test and set: if (name in self.default and setting in self.default[name]): - if type(value) == type(self.default[name][setting]): + if (isinstance(value, basestring) and + isinstance(self.default[name][setting], basestring)): + self.data[name][setting] = value + elif type(value) == type(self.default[name][setting]): self.data[name][setting] = value else: print >> sys.stderr, ("WARNING: ignoring key with wrong type " @@ -482,10 +485,11 @@ class ConfigManager(object): # Check value to see if right type: if type(value) == long: value = int(value) - if type(value) == unicode: - value = str(value) if self.has_default(key): - if type(self.get_default(key)) != type(value): + if (isinstance(self.get_default(key), basestring) and + isinstance(value, basestring)): + pass # ok + elif type(self.get_default(key)) != type(value): raise AttributeError("attempting to set '%s' to wrong type " "'%s'; should be '%s'" % (key, type(value),