Initial pass at low-hanging python3 fruit.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import websocket
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
5
setup.py
5
setup.py
@@ -25,7 +25,10 @@ setup(
|
||||
],
|
||||
keywords='websockets',
|
||||
scripts=["bin/wsdump.py"],
|
||||
install_requires=['backports.ssl_match_hostname'],
|
||||
install_requires=[
|
||||
'backports.ssl_match_hostname',
|
||||
'six',
|
||||
],
|
||||
packages=["tests", "websocket"],
|
||||
package_data={
|
||||
'tests': ['data/*.txt'],
|
||||
|
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
||||
import six
|
||||
import sys
|
||||
sys.path[0:0] = [""]
|
||||
|
||||
|
@@ -18,8 +18,10 @@ Copyright (C) 2010 Hiroki Ohtani(liris)
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
import six
|
||||
import socket
|
||||
|
||||
try:
|
||||
@@ -34,7 +36,13 @@ except ImportError:
|
||||
|
||||
HAVE_SSL = False
|
||||
|
||||
from urlparse import urlparse
|
||||
try:
|
||||
# python 3
|
||||
from urllib.parse import urlparse
|
||||
except ImportError:
|
||||
# python 2
|
||||
from urlparse import urlparse
|
||||
|
||||
import os
|
||||
import array
|
||||
import struct
|
||||
@@ -300,7 +308,7 @@ class ABNF(object):
|
||||
|
||||
fin: fin flag. if set to 0, create continue fragmentation.
|
||||
"""
|
||||
if opcode == ABNF.OPCODE_TEXT and isinstance(data, unicode):
|
||||
if opcode == ABNF.OPCODE_TEXT and isinstance(data, six.text_type):
|
||||
data = data.encode("utf-8")
|
||||
# mask must be set if send data from client
|
||||
return ABNF(fin, 0, 0, 0, opcode, 1, data)
|
||||
@@ -519,7 +527,7 @@ class WebSocket(object):
|
||||
self.connected = True
|
||||
|
||||
def _validate_header(self, headers, key):
|
||||
for k, v in _HEADERS_TO_CHECK.iteritems():
|
||||
for k, v in _HEADERS_TO_CHECK.items():
|
||||
r = headers.get(k, None)
|
||||
if not r:
|
||||
return False
|
||||
|
Reference in New Issue
Block a user