unicode decode error with UnicodeOption

This commit is contained in:
Emmanuel Garette 2017-02-02 08:56:01 +01:00
parent 2db15e193e
commit 1fba3394fe
1 changed files with 9 additions and 2 deletions

View File

@ -30,8 +30,15 @@ def display_list(lst, separator='and'):
else:
lst_ = []
for l in lst[:-1]:
lst_.append(str(l))
return ', '.join(lst_) + _(' {} ').format(separator) + str(lst[-1])
if isinstance(l, unicode):
l = l.encode('utf8')
elif not isinstance(l, str):
l = str(l)
lst_.append(l)
last = lst[-1]
if isinstance(last, unicode):
last = last.encode('utf8')
return ', '.join(lst_) + _(' {} ').format(separator) + last
# Exceptions for an Option