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:
parent
17c5e28727
commit
fbcd4b9767
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user