From 1fba3394fe0fd055cddec58786fed642a8758850 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 2 Feb 2017 08:56:01 +0100 Subject: [PATCH] unicode decode error with UnicodeOption --- tiramisu/error.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tiramisu/error.py b/tiramisu/error.py index 04d94ae..8caf819 100644 --- a/tiramisu/error.py +++ b/tiramisu/error.py @@ -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