This repository was archived by the owner on Jan 11, 2021. It is now read-only.
This repository was archived by the owner on Jan 11, 2021. It is now read-only.
UnicodeDecodeError in Python 2.7 for non-200 OK response #794
Open
Description
I'm encountered this when I tried to restrict access to the Swagger view to only staff members by mimicking get_swagger_view
with permission_classes
set to (IsAdminUser,)
instead of (AllowAny)
. When I try to access this view while not logged in, I get an UnicodeDecodeError instead of the expected 401 response. I have my language set to Swedish so the response will contain non-ascii characters.
data={u'detail': u'Autentiseringsuppgifter ej tillhandah\xe5llna.'}
The UnicodeEncodeError happens at renderers.py#58.
It works fine for me when I change
return JSONRenderer().render(data)
at renderers.py#31 to
force_bytes(json.dumps(data))
which it already does for the 200 OK case via the OpenAPICodec
encode call.
My setup:
django-rest-swagger: 2.2.0
djangorestframework: 3.7.7
Django: 1.11.17
Python 2.7
Language: sv_SE
Metadata
Metadata
Assignees
Labels
No labels