From 338d5ab0ae22b91958855e27685f301fd6509add Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 22 Nov 2019 11:22:15 +0000 Subject: [PATCH] Show nicer warning when `ujson` isn't installed (#728) --- starlette/responses.py | 1 + 1 file changed, 1 insertion(+) diff --git a/starlette/responses.py b/starlette/responses.py index 7d5afbae..e843a1e4 100644 --- a/starlette/responses.py +++ b/starlette/responses.py @@ -156,6 +156,7 @@ class UJSONResponse(JSONResponse): media_type = "application/json" def render(self, content: typing.Any) -> bytes: + assert ujson is not None, "ujson must be installed to use UJSONResponse" return ujson.dumps(content, ensure_ascii=False).encode("utf-8")