mirror of https://github.com/sipwise/repoapi.git
In Python3 all strings are considered Unicode by default. The unicode type from Python 2 is called str in Python 3, and str becomes bytes. In Python3, there aren’t any automatic conversions between str and bytes though. The json.loads in Python versions >3 and <3.6 expects a string representation and not bytes. As we receive bytes we need to decode() it, as this always returns str, just as needed. Fixes: | File "./release_dashboard/views/build.py", line 59, in hotfix_build | json_data = json.loads(request.body) | File "/usr/lib/python3.4/json/__init__.py", line 312, in loads | s.__class__.__name__)) | TypeError: the JSON object must be str, not 'bytes' See https://docs.djangoproject.com/en/1.11/topics/python3/ and https://vinta.ws/code/notes-of-porting-to-python-3-for-a-django-project.html for related documentation. Change-Id: I3984c5fd1f79b94680e680c8da64dd0ac111cbe9changes/93/14693/1
parent
63d904d977
commit
541e5418ac
Loading…
Reference in new issue