drop python<3.6 support

Filter all code over `pyupgrade --py36-plus` and update `classifiers`.
This commit is contained in:
Tomasz Kłoczko 2024-08-29 16:30:36 +02:00 committed by Pierre Ossman
parent b6c02b13e3
commit 3f205f7cc6
8 changed files with 22 additions and 21 deletions

View File

@ -14,12 +14,13 @@ setup(name=name,
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
], ],
keywords='noVNC websockify', keywords='noVNC websockify',
license='LGPLv3', license='LGPLv3',

View File

@ -29,7 +29,7 @@ from websockify import token_plugins
from websockify import auth_plugins from websockify import auth_plugins
class FakeSocket(object): class FakeSocket:
def __init__(self, data=b''): def __init__(self, data=b''):
self._data = data self._data = data
@ -47,7 +47,7 @@ class FakeSocket(object):
return StringIO(self._data.decode('latin_1')) return StringIO(self._data.decode('latin_1'))
class FakeServer(object): class FakeServer:
class EClose(Exception): class EClose(Exception):
pass pass
@ -60,7 +60,7 @@ class FakeServer(object):
class ProxyRequestHandlerTestCase(unittest.TestCase): class ProxyRequestHandlerTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
super(ProxyRequestHandlerTestCase, self).setUp() super().setUp()
self.handler = websocketproxy.ProxyRequestHandler( self.handler = websocketproxy.ProxyRequestHandler(
FakeSocket(), "127.0.0.1", FakeServer()) FakeSocket(), "127.0.0.1", FakeServer())
self.handler.path = "https://localhost:6080/websockify?token=blah" self.handler.path = "https://localhost:6080/websockify?token=blah"
@ -69,7 +69,7 @@ class ProxyRequestHandlerTestCase(unittest.TestCase):
def tearDown(self): def tearDown(self):
patch.stopall() patch.stopall()
super(ProxyRequestHandlerTestCase, self).tearDown() super().tearDown()
def test_get_target(self): def test_get_target(self):
class TestPlugin(token_plugins.BasePlugin): class TestPlugin(token_plugins.BasePlugin):

View File

@ -39,7 +39,7 @@ def raise_oserror(*args, **kwargs):
raise OSError('fake error') raise OSError('fake error')
class FakeSocket(object): class FakeSocket:
def __init__(self, data=b''): def __init__(self, data=b''):
self._data = data self._data = data
@ -59,7 +59,7 @@ class FakeSocket(object):
class WebSockifyRequestHandlerTestCase(unittest.TestCase): class WebSockifyRequestHandlerTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
super(WebSockifyRequestHandlerTestCase, self).setUp() super().setUp()
self.tmpdir = tempfile.mkdtemp('-websockify-tests') self.tmpdir = tempfile.mkdtemp('-websockify-tests')
# Mock this out cause it screws tests up # Mock this out cause it screws tests up
patch('os.chdir').start() patch('os.chdir').start()
@ -68,7 +68,7 @@ class WebSockifyRequestHandlerTestCase(unittest.TestCase):
"""Called automatically after each test.""" """Called automatically after each test."""
patch.stopall() patch.stopall()
os.rmdir(self.tmpdir) os.rmdir(self.tmpdir)
super(WebSockifyRequestHandlerTestCase, self).tearDown() super().tearDown()
def _get_server(self, handler_class=websockifyserver.WebSockifyRequestHandler, def _get_server(self, handler_class=websockifyserver.WebSockifyRequestHandler,
**kwargs): **kwargs):
@ -101,7 +101,7 @@ class WebSockifyRequestHandlerTestCase(unittest.TestCase):
class WebSockifyServerTestCase(unittest.TestCase): class WebSockifyServerTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
super(WebSockifyServerTestCase, self).setUp() super().setUp()
self.tmpdir = tempfile.mkdtemp('-websockify-tests') self.tmpdir = tempfile.mkdtemp('-websockify-tests')
# Mock this out cause it screws tests up # Mock this out cause it screws tests up
patch('os.chdir').start() patch('os.chdir').start()
@ -110,7 +110,7 @@ class WebSockifyServerTestCase(unittest.TestCase):
"""Called automatically after each test.""" """Called automatically after each test."""
patch.stopall() patch.stopall()
os.rmdir(self.tmpdir) os.rmdir(self.tmpdir)
super(WebSockifyServerTestCase, self).tearDown() super().tearDown()
def _get_server(self, handler_class=websockifyserver.WebSockifyRequestHandler, def _get_server(self, handler_class=websockifyserver.WebSockifyRequestHandler,
**kwargs): **kwargs):
@ -181,7 +181,7 @@ class WebSockifyServerTestCase(unittest.TestCase):
sock, '127.0.0.1') sock, '127.0.0.1')
def test_do_handshake_no_ssl(self): def test_do_handshake_no_ssl(self):
class FakeHandler(object): class FakeHandler:
CALLED = False CALLED = False
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
type(self).CALLED = True type(self).CALLED = True
@ -256,7 +256,7 @@ class WebSockifyServerTestCase(unittest.TestCase):
def test_do_handshake_ssl_sets_ciphers(self): def test_do_handshake_ssl_sets_ciphers(self):
test_ciphers = 'TEST-CIPHERS-1:TEST-CIPHER-2' test_ciphers = 'TEST-CIPHERS-1:TEST-CIPHER-2'
class FakeHandler(object): class FakeHandler:
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
pass pass
@ -291,7 +291,7 @@ class WebSockifyServerTestCase(unittest.TestCase):
def test_do_handshake_ssl_sets_opions(self): def test_do_handshake_ssl_sets_opions(self):
test_options = 0xCAFEBEEF test_options = 0xCAFEBEEF
class FakeHandler(object): class FakeHandler:
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
pass pass
@ -302,7 +302,7 @@ class WebSockifyServerTestCase(unittest.TestCase):
def fake_select(rlist, wlist, xlist, timeout=None): def fake_select(rlist, wlist, xlist, timeout=None):
return ([sock], [], []) return ([sock], [], [])
class fake_create_default_context(object): class fake_create_default_context:
OPTIONS = 0 OPTIONS = 0
def __init__(self, purpose): def __init__(self, purpose):
self.verify_mode = None self.verify_mode = None

View File

@ -102,7 +102,7 @@ class WebsockifySysLogHandler(handlers.SysLogHandler):
if self.unixsocket: if self.unixsocket:
try: try:
self.socket.send(msg) self.socket.send(msg)
except socket.error: except OSError:
self._connect_unixsocket(self.address) self._connect_unixsocket(self.address)
self.socket.send(msg) self.socket.send(msg)

View File

@ -37,7 +37,7 @@ class ReadOnlyTokenFile(BasePlugin):
for line in [l.strip() for l in open(f).readlines()]: for line in [l.strip() for l in open(f).readlines()]:
if line and not line.startswith('#'): if line and not line.startswith('#'):
try: try:
tok, target = re.split(':\s', line) tok, target = re.split(r':\s', line)
self._targets[tok] = target.strip().rsplit(':', 1) self._targets[tok] = target.strip().rsplit(':', 1)
except ValueError: except ValueError:
logger.error("Syntax error in %s on line %d" % (self.source, index)) logger.error("Syntax error in %s on line %d" % (self.source, index))

View File

@ -36,7 +36,7 @@ class WebSocketWantReadError(ssl.SSLWantReadError):
class WebSocketWantWriteError(ssl.SSLWantWriteError): class WebSocketWantWriteError(ssl.SSLWantWriteError):
pass pass
class WebSocket(object): class WebSocket:
"""WebSocket protocol socket like class. """WebSocket protocol socket like class.
This provides access to the WebSocket protocol by behaving much This provides access to the WebSocket protocol by behaving much

View File

@ -198,7 +198,7 @@ Traffic Legend:
if cqueue or c_pend: wlist.append(self.request) if cqueue or c_pend: wlist.append(self.request)
try: try:
ins, outs, excepts = select.select(rlist, wlist, [], 1) ins, outs, excepts = select.select(rlist, wlist, [], 1)
except (select.error, OSError): except OSError:
exc = sys.exc_info()[1] exc = sys.exc_info()[1]
if hasattr(exc, 'errno'): if hasattr(exc, 'errno'):
err = exc.errno err = exc.errno

View File

@ -187,11 +187,11 @@ class WebSockifyRequestHandler(WebSocketRequestHandlerMixIn, SimpleHTTPRequestHa
""" Send a WebSocket orderly close frame. """ """ Send a WebSocket orderly close frame. """
self.request.shutdown(socket.SHUT_RDWR, code, reason) 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. """ """ Send a WebSocket pong frame. """
self.request.pong(data) self.request.pong(data)
def send_ping(self, data=''.encode('ascii')): def send_ping(self, data=b''):
""" Send a WebSocket ping frame. """ """ Send a WebSocket ping frame. """
self.request.ping(data) self.request.ping(data)