[PATCH] [fix, calendar] Ensure that the buffer is a string

Simon Chabot simon.chabot at logilab.fr
Thu Mar 5 16:09:04 CET 2020


# HG changeset patch
# User Simon Chabot <simon.chabot at logilab.fr>
# Date 1583420606 -3600
#      Thu Mar 05 16:03:26 2020 +0100
# Branch 3.26
# Node ID d1c953c97d3955af795440849b3464ae457671a9
# Parent  b748fa6b5796a7f7da32f6cdedf3e9831be3f9ec
# Available At https://hg.logilab.org/review/cubicweb/
#              hg pull https://hg.logilab.org/review/cubicweb/ -r d1c953c97d39
[fix, calendar] Ensure that the buffer is a string

'unicode' is not defined in python3

diff -r b748fa6b5796 -r d1c953c97d39 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:



More information about the cubicweb-devel mailing list