diff --git a/sanic/request.py b/sanic/request.py index 4f5d0bdc..734ad0a3 100644 --- a/sanic/request.py +++ b/sanic/request.py @@ -1,7 +1,5 @@ import asyncio import email.utils -import json -import sys import warnings from collections import defaultdict, namedtuple @@ -23,14 +21,7 @@ from sanic.log import error_logger, logger try: from ujson import loads as json_loads except ImportError: - if sys.version_info[:2] == (3, 5): - - def json_loads(data): - # on Python 3.5 json.loads only supports str not bytes - return json.loads(data.decode()) - - else: - json_loads = json.loads + from json import loads as json_loads DEFAULT_HTTP_CONTENT_TYPE = "application/octet-stream" EXPECT_HEADER = "EXPECT" diff --git a/sanic/response.py b/sanic/response.py index 6f937c95..e339819f 100644 --- a/sanic/response.py +++ b/sanic/response.py @@ -12,7 +12,7 @@ from sanic.helpers import STATUS_CODES, has_message_body, remove_entity_headers try: from ujson import dumps as json_dumps -except BaseException: +except ImportError: from json import dumps # This is done in order to ensure that the JSON response is