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 :: 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',

View File

@ -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):

View File

@ -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

View File

@ -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)

View File

@ -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))

View File

@ -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

View File

@ -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

View File

@ -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)