python 3.5 support
[tiramisu.git] / tiramisu / error.py
index a904bd3..011fd35 100644 (file)
@@ -16,6 +16,7 @@
 # ____________________________________________________________
 "user defined exceptions"
 from .i18n import _
+import sys
 
 
 def display_list(lst, separator='and'):
@@ -27,21 +28,22 @@ def display_list(lst, separator='and'):
         return ''
     elif len(lst) == 1:
         ret = lst[0]
-        if isinstance(ret, unicode):
+        if sys.version_info[0] < 3 and isinstance(ret, unicode):
             ret = ret.encode('utf8')
         if not isinstance(ret, str):
             ret = str(ret)
         return ret
     else:
+        lst.sort()
         lst_ = []
         for l in lst[:-1]:
-            if isinstance(l, unicode):
+            if sys.version_info[0] < 3 and 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):
+        if sys.version_info[0] < 3 and isinstance(last, unicode):
             last = last.encode('utf8')
         if not isinstance(last, str):
             last = str(last)