Commit ba1a08be authored by Jérome Perrin's avatar Jérome Perrin

*: response.write expects bytes

parent 2a25c175
...@@ -20,7 +20,7 @@ zipfile (bool) ...@@ -20,7 +20,7 @@ zipfile (bool)
When true, the result is a zip file containing profiling result along with the python code (and, when not possible, the disassembled bytecode) of all files which appear in the profiling result. When true, the result is a zip file containing profiling result along with the python code (and, when not possible, the disassembled bytecode) of all files which appear in the profiling result.
When false, the result is a bare profiling result (cachegrind file format). When false, the result is a bare profiling result (cachegrind file format).
""" """
from six.moves import cStringIO as StringIO import io
portal = context.getPortalObject() portal = context.getPortalObject()
if statistic: if statistic:
profiler, retriever = portal.ERP5Site_getStatisticalProfilerAndThread(single=True) profiler, retriever = portal.ERP5Site_getStatisticalProfilerAndThread(single=True)
...@@ -39,7 +39,7 @@ if zipfile: ...@@ -39,7 +39,7 @@ if zipfile:
data, content_type = profiler.asZip() data, content_type = profiler.asZip()
filename = 'statistical_' + filename + '.zip' filename = 'statistical_' + filename + '.zip'
else: else:
out = StringIO() out = io.BytesIO()
profiler.callgrind(out, relative_path=True) profiler.callgrind(out, relative_path=True)
data = out.getvalue() data = out.getvalue()
content_type = 'application/x-kcachegrind' content_type = 'application/x-kcachegrind'
......
...@@ -17,9 +17,9 @@ try: ...@@ -17,9 +17,9 @@ try:
except Exception as e: except Exception as e:
response.setStatus(500) response.setStatus(500)
try: try:
response.write(str(e[1])) response.write(str(e[1]).encode())
except Exception: except Exception:
response.write(str(e)) response.write(str(e).encode())
return return
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment