diff --git a/setup.py b/setup.py index 51adeaf..f0c281f 100644 --- a/setup.py +++ b/setup.py @@ -14,12 +14,13 @@ setup(name=name, "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], keywords='noVNC websockify', license='LGPLv3', diff --git a/tests/test_websocketproxy.py b/tests/test_websocketproxy.py index a05e3b1..2980476 100644 --- a/tests/test_websocketproxy.py +++ b/tests/test_websocketproxy.py @@ -29,7 +29,7 @@ from websockify import token_plugins from websockify import auth_plugins -class FakeSocket(object): +class FakeSocket: def __init__(self, data=b''): self._data = data @@ -47,7 +47,7 @@ class FakeSocket(object): return StringIO(self._data.decode('latin_1')) -class FakeServer(object): +class FakeServer: class EClose(Exception): pass @@ -60,7 +60,7 @@ class FakeServer(object): class ProxyRequestHandlerTestCase(unittest.TestCase): def setUp(self): - super(ProxyRequestHandlerTestCase, self).setUp() + super().setUp() self.handler = websocketproxy.ProxyRequestHandler( FakeSocket(), "127.0.0.1", FakeServer()) self.handler.path = "https://localhost:6080/websockify?token=blah" @@ -69,7 +69,7 @@ class ProxyRequestHandlerTestCase(unittest.TestCase): def tearDown(self): patch.stopall() - super(ProxyRequestHandlerTestCase, self).tearDown() + super().tearDown() def test_get_target(self): class TestPlugin(token_plugins.BasePlugin): diff --git a/tests/test_websockifyserver.py b/tests/test_websockifyserver.py index 79d1b25..42edb4a 100644 --- a/tests/test_websockifyserver.py +++ b/tests/test_websockifyserver.py @@ -39,7 +39,7 @@ def raise_oserror(*args, **kwargs): raise OSError('fake error') -class FakeSocket(object): +class FakeSocket: def __init__(self, data=b''): self._data = data @@ -59,7 +59,7 @@ class FakeSocket(object): class WebSockifyRequestHandlerTestCase(unittest.TestCase): def setUp(self): - super(WebSockifyRequestHandlerTestCase, self).setUp() + super().setUp() self.tmpdir = tempfile.mkdtemp('-websockify-tests') # Mock this out cause it screws tests up patch('os.chdir').start() @@ -68,7 +68,7 @@ class WebSockifyRequestHandlerTestCase(unittest.TestCase): """Called automatically after each test.""" patch.stopall() os.rmdir(self.tmpdir) - super(WebSockifyRequestHandlerTestCase, self).tearDown() + super().tearDown() def _get_server(self, handler_class=websockifyserver.WebSockifyRequestHandler, **kwargs): @@ -101,7 +101,7 @@ class WebSockifyRequestHandlerTestCase(unittest.TestCase): class WebSockifyServerTestCase(unittest.TestCase): def setUp(self): - super(WebSockifyServerTestCase, self).setUp() + super().setUp() self.tmpdir = tempfile.mkdtemp('-websockify-tests') # Mock this out cause it screws tests up patch('os.chdir').start() @@ -110,7 +110,7 @@ class WebSockifyServerTestCase(unittest.TestCase): """Called automatically after each test.""" patch.stopall() os.rmdir(self.tmpdir) - super(WebSockifyServerTestCase, self).tearDown() + super().tearDown() def _get_server(self, handler_class=websockifyserver.WebSockifyRequestHandler, **kwargs): @@ -181,7 +181,7 @@ class WebSockifyServerTestCase(unittest.TestCase): sock, '127.0.0.1') def test_do_handshake_no_ssl(self): - class FakeHandler(object): + class FakeHandler: CALLED = False def __init__(self, *args, **kwargs): type(self).CALLED = True @@ -256,7 +256,7 @@ class WebSockifyServerTestCase(unittest.TestCase): def test_do_handshake_ssl_sets_ciphers(self): test_ciphers = 'TEST-CIPHERS-1:TEST-CIPHER-2' - class FakeHandler(object): + class FakeHandler: def __init__(self, *args, **kwargs): pass @@ -291,7 +291,7 @@ class WebSockifyServerTestCase(unittest.TestCase): def test_do_handshake_ssl_sets_opions(self): test_options = 0xCAFEBEEF - class FakeHandler(object): + class FakeHandler: def __init__(self, *args, **kwargs): pass @@ -302,7 +302,7 @@ class WebSockifyServerTestCase(unittest.TestCase): def fake_select(rlist, wlist, xlist, timeout=None): return ([sock], [], []) - class fake_create_default_context(object): + class fake_create_default_context: OPTIONS = 0 def __init__(self, purpose): self.verify_mode = None diff --git a/websockify/sysloghandler.py b/websockify/sysloghandler.py index 37ee9dd..480bac2 100644 --- a/websockify/sysloghandler.py +++ b/websockify/sysloghandler.py @@ -102,7 +102,7 @@ class WebsockifySysLogHandler(handlers.SysLogHandler): if self.unixsocket: try: self.socket.send(msg) - except socket.error: + except OSError: self._connect_unixsocket(self.address) self.socket.send(msg) diff --git a/websockify/token_plugins.py b/websockify/token_plugins.py index 36a1dbc..9c36383 100644 --- a/websockify/token_plugins.py +++ b/websockify/token_plugins.py @@ -37,7 +37,7 @@ class ReadOnlyTokenFile(BasePlugin): for line in [l.strip() for l in open(f).readlines()]: if line and not line.startswith('#'): try: - tok, target = re.split(':\s', line) + tok, target = re.split(r':\s', line) self._targets[tok] = target.strip().rsplit(':', 1) except ValueError: logger.error("Syntax error in %s on line %d" % (self.source, index)) diff --git a/websockify/websocket.py b/websockify/websocket.py index ee7dc83..1bed8cc 100644 --- a/websockify/websocket.py +++ b/websockify/websocket.py @@ -36,7 +36,7 @@ class WebSocketWantReadError(ssl.SSLWantReadError): class WebSocketWantWriteError(ssl.SSLWantWriteError): pass -class WebSocket(object): +class WebSocket: """WebSocket protocol socket like class. This provides access to the WebSocket protocol by behaving much diff --git a/websockify/websocketproxy.py b/websockify/websocketproxy.py index b6f103c..141db88 100644 --- a/websockify/websocketproxy.py +++ b/websockify/websocketproxy.py @@ -198,7 +198,7 @@ Traffic Legend: if cqueue or c_pend: wlist.append(self.request) try: ins, outs, excepts = select.select(rlist, wlist, [], 1) - except (select.error, OSError): + except OSError: exc = sys.exc_info()[1] if hasattr(exc, 'errno'): err = exc.errno diff --git a/websockify/websockifyserver.py b/websockify/websockifyserver.py index 94e63bd..78613fb 100644 --- a/websockify/websockifyserver.py +++ b/websockify/websockifyserver.py @@ -187,11 +187,11 @@ class WebSockifyRequestHandler(WebSocketRequestHandlerMixIn, SimpleHTTPRequestHa """ Send a WebSocket orderly close frame. """ self.request.shutdown(socket.SHUT_RDWR, code, reason) - def send_pong(self, data=''.encode('ascii')): + def send_pong(self, data=b''): """ Send a WebSocket pong frame. """ self.request.pong(data) - def send_ping(self, data=''.encode('ascii')): + def send_ping(self, data=b''): """ Send a WebSocket ping frame. """ self.request.ping(data)