Merge pull request #722 from messense/feature/ci-without-ext

Add py3*-no-ext test env
This commit is contained in:
Raphael Deem
2017-05-17 12:47:05 -07:00
committed by GitHub
5 changed files with 49 additions and 18 deletions

View File

@@ -206,7 +206,12 @@ class Sanic:
def response(handler):
async def websocket_handler(request, *args, **kwargs):
request.app = self
protocol = request.transport.get_protocol()
try:
protocol = request.transport.get_protocol()
except AttributeError:
# On Python3.5 the Transport classes in asyncio do not
# have a get_protocol() method as in uvloop
protocol = request.transport._protocol
ws = await protocol.websocket_handshake(request)
# schedule the application handler

View File

@@ -1,3 +1,5 @@
import sys
import json
from cgi import parse_header
from collections import namedtuple
from http.cookies import SimpleCookie
@@ -7,7 +9,12 @@ from urllib.parse import parse_qs, urlunparse
try:
from ujson import loads as json_loads
except ImportError:
from json import loads as json_loads
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 sanic.exceptions import InvalidUsage
from sanic.log import log