__str__ method could return unicode object, force to decode in str
[tiramisu.git] / tiramisu / config.py
index 7152ea6..eb4dd77 100644 (file)
@@ -23,7 +23,7 @@
 from tiramisu.error import PropertiesOptionError, ConfigError
 from tiramisu.option import OptionDescription, Option, SymLinkOption, \
     BaseInformation
-from tiramisu.setting import groups, Setting
+from tiramisu.setting import groups, Setting, default_encoding
 from tiramisu.value import Values
 from tiramisu.i18n import _
 
@@ -133,10 +133,11 @@ class SubConfig(BaseInformation):
         "Config's string representation"
         lines = []
         for name, grp in self.iter_groups():
-            lines.append("[%s]" % name)
+            lines.append("[{0}]".format(name))
         for name, value in self:
+            value = value.encode(default_encoding)
             try:
-                lines.append("%s = %s" % (name, value))
+                lines.append("{0} = {1}".format(name, value))
             except PropertiesOptionError:
                 pass
         return '\n'.join(lines)