Config: __str__ raise if no str/unicode value

This commit is contained in:
2013-07-03 21:56:19 +02:00
parent 0afb521766
commit c06659012b
2 changed files with 17 additions and 2 deletions

View File

@ -135,9 +135,11 @@ class SubConfig(BaseInformation):
for name, grp in self.iter_groups():
lines.append("[{0}]".format(name))
for name, value in self:
value = value.encode(default_encoding)
try:
lines.append("{0} = {1}".format(name, value))
except UnicodeEncodeError:
lines.append("{0} = {1}".format(name,
value.encode(default_encoding)))
except PropertiesOptionError:
pass
return '\n'.join(lines)