[fix, calendar] Ensure that the buffer is a string 3.26
authorSimon Chabot <simon.chabot@logilab.fr>
Thu, 05 Mar 2020 16:03:26 +0100
branch3.26
changeset 12907 d1c953c97d39
parent 12906 b748fa6b5796
child 12908 5c6d242069b6
[fix, calendar] Ensure that the buffer is a string 'unicode' is not defined in python3
cubicweb/web/views/calendar.py
--- a/cubicweb/web/views/calendar.py	Thu Mar 05 10:41:30 2020 +0100
+++ b/cubicweb/web/views/calendar.py	Thu Mar 05 16:03:26 2020 +0100
@@ -23,6 +23,7 @@
 import copy
 from datetime import timedelta
 
+import six
 from logilab.mtconverter import xml_escape
 from logilab.common.date import todatetime
 
@@ -100,9 +101,7 @@
                 if ical_task.stop:
                     elt.add(stop_kw).value = ical_task.stop
 
-            buff = ical.serialize()
-            if not isinstance(buff, unicode):
-                buff = unicode(buff, self._cw.encoding)
+            buff = six.ensure_str(ical.serialize(), encoding=self._cw.encoding)
             self.w(buff)
 
 except ImportError: