Skip to content
Snippets Groups Projects
Commit 18e4be54 authored by David Douard's avatar David Douard
Browse files

api: fix swh.core.api.decode_request on python 3.5

The json decoder was broken on py35, as is used to expect a str object and
not a bytes one. For now, we encode the bytes one using utf-8.

This could/should be reverted as soon as we drop support for py35.
parent ec7c3f84
No related branches found
No related tags found
1 merge request!90api: fix swh.core.api.decode_request on python 3.5
......@@ -278,7 +278,9 @@ def decode_request(request):
if content_type == 'application/x-msgpack':
r = msgpack_loads(data)
elif content_type == 'application/json':
r = json.loads(data, cls=SWHJSONDecoder)
# XXX this .decode() is needed for py35.
# Should not be needed any more with py37
r = json.loads(data.decode('utf-8'), cls=SWHJSONDecoder)
else:
raise ValueError('Wrong content type `%s` for API request'
% content_type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment