Commit a5656815 authored by Carine Dengler's avatar Carine Dengler
Browse files

[py3][json] json.dumps returns text type

--HG--
branch : 0.1
parent 82e04206269c
......@@ -17,6 +17,8 @@
"""cubicweb-jsonschema Pyramid views for the JSON API of entities."""
import json
from six import PY3
from pyramid import httpexceptions
from pyramid.renderers import render
from pyramid.view import view_config
......@@ -345,7 +347,10 @@ def generic_error(exc, request):
if isinstance(exc, httpexceptions.HTTPException):
if exc.content_type != 'application/json':
exc.content_type = 'application/json'
exc.body = json.dumps({'message': exc.detail})
body = json.dumps({'message': exc.detail})
if PY3:
body = body.encode('utf-8')
exc.body = body
return exc
request.cw_cnx.rollback()
LOG.exception('exception occurred while processing %s', request)
......
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