Sanic does not support Python 3.5 and won't need this code. (#1670)

* imports code cleanup as we dropping python3.5 support
This commit is contained in:
L. Kärkkäinen 2019-09-09 00:08:34 +03:00 committed by 7
parent 17c5e28727
commit fbcd4b9767
2 changed files with 2 additions and 11 deletions

View File

@ -1,7 +1,5 @@
import asyncio import asyncio
import email.utils import email.utils
import json
import sys
import warnings import warnings
from collections import defaultdict, namedtuple from collections import defaultdict, namedtuple
@ -23,14 +21,7 @@ from sanic.log import error_logger, logger
try: try:
from ujson import loads as json_loads from ujson import loads as json_loads
except ImportError: except ImportError:
if sys.version_info[:2] == (3, 5): from json import loads as json_loads
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
DEFAULT_HTTP_CONTENT_TYPE = "application/octet-stream" DEFAULT_HTTP_CONTENT_TYPE = "application/octet-stream"
EXPECT_HEADER = "EXPECT" EXPECT_HEADER = "EXPECT"

View File

@ -12,7 +12,7 @@ from sanic.helpers import STATUS_CODES, has_message_body, remove_entity_headers
try: try:
from ujson import dumps as json_dumps from ujson import dumps as json_dumps
except BaseException: except ImportError:
from json import dumps from json import dumps
# This is done in order to ensure that the JSON response is # This is done in order to ensure that the JSON response is