[PATCH 4 of 5 timesheet] [views] jsonp expects binary (fix py3/py2 issue)

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


# HG changeset patch
# User Simon Chabot <simon.chabot at logilab.fr>
# Date 1583404732 -3600
#      Thu Mar 05 11:38:52 2020 +0100
# Node ID b2e4994d271b7b2052ffce488059c50b7e5fbe00
# Parent  65e3d47131cb2b1999e9f8a59e92c6ff3684581c
# Available At https://hg.logilab.org/review/cubes/timesheet/
#              hg pull https://hg.logilab.org/review/cubes/timesheet/ -r b2e4994d271b
[views] jsonp expects binary (fix py3/py2 issue)

diff -r 65e3d47131cb -r b2e4994d271b cubicweb_timesheet/views/jsonp.py
--- a/cubicweb_timesheet/views/jsonp.py	Thu Mar 05 11:29:14 2020 +0100
+++ b/cubicweb_timesheet/views/jsonp.py	Thu Mar 05 11:38:52 2020 +0100
@@ -3,6 +3,8 @@
 from datetime import datetime as pydatetime
 import json
 
+import six
+
 from cubicweb.view import StartupView
 from cubicweb.predicates import match_form_params
 
@@ -51,6 +53,7 @@
                              self._cw.form['stop'])
         if 'callback' in self._cw.form:
             self._cw.set_content_type('text/javascript')
-            self.w('%s(%s)' % (self._cw.form['callback'].encode('ascii'), json.dumps(data)))
+            self.w('%s(%s)' % (self._cw.form['callback'].encode('ascii'),
+                               six.ensure_binary(json.dumps(data))))
         else:
-            self.w(json.dumps(data))
+            self.w(six.ensure_binary(json.dumps(data)))



More information about the cubicweb-devel mailing list