__str__ method could return unicode object, force to decode in str

This commit is contained in:
Emmanuel Garette 2013-07-01 16:49:10 +02:00
parent b8bfa02e02
commit 4b5d9b4229
2 changed files with 5 additions and 3 deletions

View 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)

View File

@ -25,6 +25,7 @@ from copy import copy
from tiramisu.error import RequirementError, PropertiesOptionError
from tiramisu.i18n import _
default_encoding = 'utf-8'
expires_time = 5
ro_remove = ('permissive', 'hidden')