Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3fba9fa

Browse files
alan-brooksfantix
andauthored
Updates for Cython3 (#587)
* Remove SSL depreciation warnings * Use Cython 3.0 and fix deprecated test --------- Co-authored-by: Fantix King <fantix.king@gmail.com>
1 parent 3c3bbef commit 3fba9fa

File tree

15 files changed

+76
-50
lines changed

15 files changed

+76
-50
lines changed

‎Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _default: compile
99

1010

1111
clean:
12-
rm -fr dist/ doc/_build/ *.egg-info uvloop/loop.*.pyd
12+
rm -fr dist/ doc/_build/ *.egg-info uvloop/loop.*.pyd uvloop/loop_d.*.pyd
1313
rm -fr uvloop/*.c uvloop/*.html uvloop/*.so
1414
rm -fr uvloop/handles/*.html uvloop/includes/*.html
1515
find . -name '__pycache__' | xargs rm -rf

‎pyproject.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ test = [
3636
# pycodestyle is a dependency of flake8, but it must be frozen because
3737
# their combination breaks too often
3838
# (example breakage: https://gitlab.com/pycqa/flake8/issues/427)
39-
'aiohttp>=3.8.1; python_version < "3.12"',
40-
'aiohttp==3.9.0b0; python_version >= "3.12"',
39+
'aiohttp>=3.10.5',
4140
'flake8~=5.0',
4241
'psutil',
4342
'pycodestyle~=2.9.0',
4443
'pyOpenSSL~=23.0.0',
4544
'mypy>=0.800',
46-
'Cython(>=0.29.36,<0.30.0)',
45+
]
46+
dev = [
47+
'setuptools>=60',
48+
'Cython~=3.0',
4749
]
4850
docs = [
4951
'Sphinx~=4.1.2',
@@ -55,7 +57,7 @@ docs = [
5557
requires = [
5658
"setuptools>=60",
5759
"wheel",
58-
"Cython(>=0.29.36,<0.30.0)",
60+
"Cython~=3.0",
5961
]
6062
build-backend = "setuptools.build_meta"
6163

‎setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from setuptools.command.sdist import sdist
2222

2323

24-
CYTHON_DEPENDENCY = 'Cython(>=0.29.36,<0.30.0)'
24+
CYTHON_DEPENDENCY = 'Cython~=3.0'
2525
MACHINE = platform.machine()
2626
MODULES_CFLAGS = [os.getenv('UVLOOP_OPT_CFLAGS', '-O2')]
2727
_ROOT = pathlib.Path(__file__).parent
@@ -144,7 +144,9 @@ def finalize_options(self):
144144
self.distribution.ext_modules[:] = cythonize(
145145
self.distribution.ext_modules,
146146
compiler_directives=directives,
147-
annotate=self.cython_annotate)
147+
annotate=self.cython_annotate,
148+
compile_time_env=dict(DEFAULT_FREELIST_SIZE=250),
149+
emit_linenums=self.debug)
148150

149151
super().finalize_options()
150152

‎tests/test_tcp.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,17 +1631,22 @@ async def client(addr):
16311631
self.fail("unexpected call to connection_made()")
16321632

16331633
def test_ssl_connect_accepted_socket(self):
1634-
if hasattr(ssl, 'PROTOCOL_TLS'):
1635-
proto = ssl.PROTOCOL_TLS
1634+
if hasattr(ssl, 'PROTOCOL_TLS_SERVER'):
1635+
server_proto = ssl.PROTOCOL_TLS_SERVER
1636+
client_proto = ssl.PROTOCOL_TLS_CLIENT
16361637
else:
1637-
proto = ssl.PROTOCOL_SSLv23
1638-
server_context = ssl.SSLContext(proto)
1638+
if hasattr(ssl, 'PROTOCOL_TLS'):
1639+
client_proto = server_proto = ssl.PROTOCOL_TLS
1640+
else:
1641+
client_proto = server_proto = ssl.PROTOCOL_SSLv23
1642+
1643+
server_context = ssl.SSLContext(server_proto)
16391644
server_context.load_cert_chain(self.ONLYCERT, self.ONLYKEY)
16401645
if hasattr(server_context, 'check_hostname'):
16411646
server_context.check_hostname = False
16421647
server_context.verify_mode = ssl.CERT_NONE
16431648

1644-
client_context = ssl.SSLContext(proto)
1649+
client_context = ssl.SSLContext(client_proto)
16451650
if hasattr(server_context, 'check_hostname'):
16461651
client_context.check_hostname = False
16471652
client_context.verify_mode = ssl.CERT_NONE
@@ -2234,8 +2239,7 @@ def test_renegotiation(self):
22342239
sslctx.use_privatekey_file(self.ONLYKEY)
22352240
sslctx.use_certificate_chain_file(self.ONLYCERT)
22362241
client_sslctx = self._create_client_ssl_context()
2237-
if hasattr(ssl, 'OP_NO_TLSv1_3'):
2238-
client_sslctx.options |= ssl.OP_NO_TLSv1_3
2242+
client_sslctx.maximum_version = ssl.TLSVersion.TLSv1_2
22392243

22402244
def server(sock):
22412245
conn = openssl_ssl.Connection(sslctx, sock)
@@ -2593,8 +2597,7 @@ def test_flush_before_shutdown(self):
25932597
sslctx_openssl.use_privatekey_file(self.ONLYKEY)
25942598
sslctx_openssl.use_certificate_chain_file(self.ONLYCERT)
25952599
client_sslctx = self._create_client_ssl_context()
2596-
if hasattr(ssl, 'OP_NO_TLSv1_3'):
2597-
client_sslctx.options |= ssl.OP_NO_TLSv1_3
2600+
client_sslctx.maximum_version = ssl.TLSVersion.TLSv1_2
25982601

25992602
future = None
26002603

‎uvloop/_testbase.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ def find_free_port(start_from=50000):
269269
class SSLTestCase:
270270

271271
def _create_server_ssl_context(self, certfile, keyfile=None):
272-
if hasattr(ssl, 'PROTOCOL_TLS'):
272+
if hasattr(ssl, 'PROTOCOL_TLS_SERVER'):
273+
sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
274+
elif hasattr(ssl, 'PROTOCOL_TLS'):
273275
sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLS)
274276
else:
275277
sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)

‎uvloop/dns.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ cdef class AddrInfo:
298298
uv.uv_freeaddrinfo(self.data) # returns void
299299
self.data = NULL
300300

301-
cdef void set_data(self, system.addrinfo *data):
301+
cdef void set_data(self, system.addrinfo *data) noexcept:
302302
self.data = data
303303

304304
cdef unpack(self):

‎uvloop/handles/handle.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ cdef void __uv_close_handle_cb(uv.uv_handle_t* handle) noexcept with gil:
363363
Py_DECREF(h) # Was INCREFed in UVHandle._close
364364

365365

366-
cdef void __close_all_handles(Loop loop):
366+
cdef void __close_all_handles(Loop loop) noexcept:
367367
uv.uv_walk(loop.uvloop,
368368
__uv_walk_close_all_handles_cb,
369369
<void*>loop) # void

‎uvloop/handles/pipe.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cdef __pipe_init_uv_handle(UVStream handle, Loop loop):
2525
cdef __pipe_open(UVStream handle, int fd):
2626
cdef int err
2727
err = uv.uv_pipe_open(<uv.uv_pipe_t *>handle._handle,
28-
<uv.uv_file>fd)
28+
<uv.uv_os_fd_t>fd)
2929
if err < 0:
3030
exc = convert_error(err)
3131
raise exc

‎uvloop/handles/poll.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cdef class UVPoll(UVHandle):
1010
cdef inline _poll_start(self, int flags)
1111
cdef inline _poll_stop(self)
1212

13-
cdef int is_active(self)
13+
cdef int is_active(self) noexcept
1414

1515
cdef is_reading(self)
1616
cdef is_writing(self)

‎uvloop/handles/poll.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cdef class UVPoll(UVHandle):
2929
handle._init(loop, fd)
3030
return handle
3131

32-
cdef int is_active(self):
32+
cdef int is_active(self) noexcept:
3333
return (self.reading_handle is not None or
3434
self.writing_handle is not None)
3535

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /