Skip to content

Commit 6f0abd4

Browse files
Matus ValoMatus Valo
Matus Valo
authored and
Matus Valo
committed
Mark functions as noexcept to ensure cython 3 compatibility
1 parent 1dd40f1 commit 6f0abd4

22 files changed

+48
-48
lines changed

uvloop/dns.pyx

+4-4
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):
@@ -326,7 +326,7 @@ cdef class AddrInfo:
326326
return result
327327

328328
@staticmethod
329-
cdef int isinstance(object other):
329+
cdef int isinstance(object other) noexcept:
330330
return type(other) is AddrInfo
331331

332332

@@ -415,7 +415,7 @@ cdef _intenum_converter(value, enum_klass):
415415

416416

417417
cdef void __on_addrinfo_resolved(uv.uv_getaddrinfo_t *resolver,
418-
int status, system.addrinfo *res) with gil:
418+
int status, system.addrinfo *res) noexcept with gil:
419419

420420
if resolver.data is NULL:
421421
aio_logger.error(
@@ -446,7 +446,7 @@ cdef void __on_addrinfo_resolved(uv.uv_getaddrinfo_t *resolver,
446446
cdef void __on_nameinfo_resolved(uv.uv_getnameinfo_t* req,
447447
int status,
448448
const char* hostname,
449-
const char* service) with gil:
449+
const char* service) noexcept with gil:
450450
cdef:
451451
NameInfoRequest request = <NameInfoRequest> req.data
452452
Loop loop = request.loop

uvloop/errors.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ cdef __convert_python_error(int uverr):
5151
return exc(oserr, __strerr(oserr))
5252

5353

54-
cdef int __convert_socket_error(int uverr):
54+
cdef int __convert_socket_error(int uverr) noexcept:
5555
cdef int sock_err = 0
5656

5757
if uverr == uv.UV_EAI_ADDRFAMILY:

uvloop/handles/async_.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ cdef class UVAsync(UVHandle):
4141
return handle
4242

4343

44-
cdef void __uvasync_callback(uv.uv_async_t* handle) with gil:
44+
cdef void __uvasync_callback(uv.uv_async_t* handle) noexcept with gil:
4545
if __ensure_handle_data(<uv.uv_handle_t*>handle, "UVAsync callback") == 0:
4646
return
4747

uvloop/handles/basetransport.pxd

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ cdef class UVBaseTransport(UVSocketHandle):
4747
# === overloads ===
4848

4949
cdef _new_socket(self)
50-
cdef size_t _get_write_buffer_size(self)
50+
cdef size_t _get_write_buffer_size(self) noexcept
5151

52-
cdef bint _is_reading(self)
52+
cdef bint _is_reading(self) noexcept
5353
cdef _start_reading(self)
5454
cdef _stop_reading(self)

uvloop/handles/basetransport.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cdef class UVBaseTransport(UVSocketHandle):
1818

1919
self._closing = 0
2020

21-
cdef size_t _get_write_buffer_size(self):
21+
cdef size_t _get_write_buffer_size(self) noexcept:
2222
return 0
2323

2424
cdef inline _schedule_call_connection_made(self):
@@ -211,7 +211,7 @@ cdef class UVBaseTransport(UVSocketHandle):
211211
self._extra_info = {}
212212
self._extra_info[name] = obj
213213

214-
cdef bint _is_reading(self):
214+
cdef bint _is_reading(self) noexcept:
215215
raise NotImplementedError
216216

217217
cdef _start_reading(self):

uvloop/handles/check.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cdef class UVCheck(UVHandle):
5757
return handle
5858

5959

60-
cdef void cb_check_callback(uv.uv_check_t* handle) with gil:
60+
cdef void cb_check_callback(uv.uv_check_t* handle) noexcept with gil:
6161
if __ensure_handle_data(<uv.uv_handle_t*>handle, "UVCheck callback") == 0:
6262
return
6363

uvloop/handles/fsevent.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ cdef class UVFSEvent(UVHandle):
9090

9191

9292
cdef void __uvfsevent_callback(uv.uv_fs_event_t* handle, const char *filename,
93-
int events, int status) with gil:
93+
int events, int status) noexcept with gil:
9494
if __ensure_handle_data(
9595
<uv.uv_handle_t*>handle, "UVFSEvent callback"
9696
) == 0:

uvloop/handles/handle.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ cdef class UVSocketHandle(UVHandle):
302302

303303

304304
cdef inline bint __ensure_handle_data(uv.uv_handle_t* handle,
305-
const char* handle_ctx):
305+
const char* handle_ctx) noexcept:
306306

307307
cdef Loop loop
308308

@@ -335,7 +335,7 @@ cdef inline bint __ensure_handle_data(uv.uv_handle_t* handle,
335335
return 1
336336

337337

338-
cdef void __uv_close_handle_cb(uv.uv_handle_t* handle) with gil:
338+
cdef void __uv_close_handle_cb(uv.uv_handle_t* handle) noexcept with gil:
339339
cdef UVHandle h
340340

341341
if handle.data is NULL:
@@ -363,14 +363,14 @@ cdef void __uv_close_handle_cb(uv.uv_handle_t* handle) 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
370370

371371

372372
cdef void __uv_walk_close_all_handles_cb(
373-
uv.uv_handle_t* handle, void* arg) with gil:
373+
uv.uv_handle_t* handle, void* arg) noexcept with gil:
374374

375375
cdef:
376376
Loop loop = <Loop>arg

uvloop/handles/idle.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cdef class UVIdle(UVHandle):
5757
return handle
5858

5959

60-
cdef void cb_idle_callback(uv.uv_idle_t* handle) with gil:
60+
cdef void cb_idle_callback(uv.uv_idle_t* handle) noexcept with gil:
6161
if __ensure_handle_data(<uv.uv_handle_t*>handle, "UVIdle callback") == 0:
6262
return
6363

uvloop/handles/pipe.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ cdef class _PipeConnectRequest(UVRequest):
202202
addr,
203203
__pipe_connect_callback)
204204

205-
cdef void __pipe_connect_callback(uv.uv_connect_t* req, int status) with gil:
205+
cdef void __pipe_connect_callback(uv.uv_connect_t* req, int status) noexcept with gil:
206206
cdef:
207207
_PipeConnectRequest wrapper
208208
UnixTransport transport

uvloop/handles/poll.pxd

+1-1
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

+2-2
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

@@ -191,7 +191,7 @@ cdef class UVPoll(UVHandle):
191191

192192

193193
cdef void __on_uvpoll_event(uv.uv_poll_t* handle,
194-
int status, int events) with gil:
194+
int status, int events) noexcept with gil:
195195

196196
if __ensure_handle_data(<uv.uv_handle_t*>handle, "UVPoll callback") == 0:
197197
return

uvloop/handles/process.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ cdef __process_convert_fileno(object obj):
732732

733733
cdef void __uvprocess_on_exit_callback(uv.uv_process_t *handle,
734734
int64_t exit_status,
735-
int term_signal) with gil:
735+
int term_signal) noexcept with gil:
736736

737737
if __ensure_handle_data(<uv.uv_handle_t*>handle,
738738
"UVProcess exit callback") == 0:
@@ -761,5 +761,5 @@ cdef __socketpair():
761761
return fds[0], fds[1]
762762

763763

764-
cdef void __uv_close_process_handle_cb(uv.uv_handle_t* handle) with gil:
764+
cdef void __uv_close_process_handle_cb(uv.uv_handle_t* handle) noexcept with gil:
765765
PyMem_RawFree(handle)

uvloop/handles/stream.pyx

+10-10
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ cdef class UVStream(UVBaseTransport):
279279
cdef inline _close_on_read_error(self):
280280
self.__read_error_close = 1
281281

282-
cdef bint _is_reading(self):
282+
cdef bint _is_reading(self) noexcept:
283283
return self.__reading
284284

285285
cdef _start_reading(self):
@@ -578,7 +578,7 @@ cdef class UVStream(UVBaseTransport):
578578

579579
self._maybe_resume_protocol()
580580

581-
cdef size_t _get_write_buffer_size(self):
581+
cdef size_t _get_write_buffer_size(self) noexcept:
582582
if self._handle is NULL:
583583
return 0
584584
return ((<uv.uv_stream_t*>self._handle).write_queue_size +
@@ -723,7 +723,7 @@ cdef class UVStream(UVBaseTransport):
723723

724724

725725
cdef void __uv_stream_on_shutdown(uv.uv_shutdown_t* req,
726-
int status) with gil:
726+
int status) noexcept with gil:
727727

728728
# callback for uv_shutdown
729729

@@ -752,7 +752,7 @@ cdef void __uv_stream_on_shutdown(uv.uv_shutdown_t* req,
752752

753753

754754
cdef inline bint __uv_stream_on_read_common(UVStream sc, Loop loop,
755-
ssize_t nread):
755+
ssize_t nread) noexcept:
756756
if sc._closed:
757757
# The stream was closed, there is no reason to
758758
# do any work now.
@@ -813,7 +813,7 @@ cdef inline bint __uv_stream_on_read_common(UVStream sc, Loop loop,
813813

814814
cdef inline void __uv_stream_on_read_impl(uv.uv_stream_t* stream,
815815
ssize_t nread,
816-
const uv.uv_buf_t* buf):
816+
const uv.uv_buf_t* buf) noexcept:
817817
cdef:
818818
UVStream sc = <UVStream>stream.data
819819
Loop loop = sc._loop
@@ -841,7 +841,7 @@ cdef inline void __uv_stream_on_read_impl(uv.uv_stream_t* stream,
841841
sc._fatal_error(exc, False)
842842

843843

844-
cdef inline void __uv_stream_on_write_impl(uv.uv_write_t* req, int status):
844+
cdef inline void __uv_stream_on_write_impl(uv.uv_write_t* req, int status) noexcept:
845845
cdef:
846846
_StreamWriteContext ctx = <_StreamWriteContext> req.data
847847
UVStream stream = <UVStream>ctx.stream
@@ -874,7 +874,7 @@ cdef inline void __uv_stream_on_write_impl(uv.uv_write_t* req, int status):
874874

875875
cdef void __uv_stream_on_read(uv.uv_stream_t* stream,
876876
ssize_t nread,
877-
const uv.uv_buf_t* buf) with gil:
877+
const uv.uv_buf_t* buf) noexcept with gil:
878878

879879
if __ensure_handle_data(<uv.uv_handle_t*>stream,
880880
"UVStream read callback") == 0:
@@ -884,7 +884,7 @@ cdef void __uv_stream_on_read(uv.uv_stream_t* stream,
884884
__uv_stream_on_read_impl(stream, nread, buf)
885885

886886

887-
cdef void __uv_stream_on_write(uv.uv_write_t* req, int status) with gil:
887+
cdef void __uv_stream_on_write(uv.uv_write_t* req, int status) noexcept with gil:
888888

889889
if UVLOOP_DEBUG:
890890
if req.data is NULL:
@@ -899,7 +899,7 @@ cdef void __uv_stream_on_write(uv.uv_write_t* req, int status) with gil:
899899

900900
cdef void __uv_stream_buffered_alloc(uv.uv_handle_t* stream,
901901
size_t suggested_size,
902-
uv.uv_buf_t* uvbuf) with gil:
902+
uv.uv_buf_t* uvbuf) noexcept with gil:
903903

904904
if __ensure_handle_data(<uv.uv_handle_t*>stream,
905905
"UVStream alloc buffer callback") == 0:
@@ -947,7 +947,7 @@ cdef void __uv_stream_buffered_alloc(uv.uv_handle_t* stream,
947947

948948
cdef void __uv_stream_buffered_on_read(uv.uv_stream_t* stream,
949949
ssize_t nread,
950-
const uv.uv_buf_t* buf) with gil:
950+
const uv.uv_buf_t* buf) noexcept with gil:
951951

952952
if __ensure_handle_data(<uv.uv_handle_t*>stream,
953953
"UVStream buffered read callback") == 0:

uvloop/handles/streamserver.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ cdef class UVStreamServer(UVSocketHandle):
122122

123123

124124
cdef void __uv_streamserver_on_listen(uv.uv_stream_t* handle,
125-
int status) with gil:
125+
int status) noexcept with gil:
126126

127127
# callback for uv_listen
128128

uvloop/handles/tcp.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ cdef class _TCPConnectRequest(UVRequest):
204204
raise exc
205205

206206

207-
cdef void __tcp_connect_callback(uv.uv_connect_t* req, int status) with gil:
207+
cdef void __tcp_connect_callback(uv.uv_connect_t* req, int status) noexcept with gil:
208208
cdef:
209209
_TCPConnectRequest wrapper
210210
TCPTransport transport

uvloop/handles/timer.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ cdef class UVTimer(UVHandle):
7272
return handle
7373

7474

75-
cdef void __uvtimer_callback(uv.uv_timer_t* handle) with gil:
75+
cdef void __uvtimer_callback(uv.uv_timer_t* handle) noexcept with gil:
7676
if __ensure_handle_data(<uv.uv_handle_t*>handle, "UVTimer callback") == 0:
7777
return
7878

uvloop/handles/udp.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ cdef class UDPTransport(UVBaseTransport):
127127
exc = convert_error(err)
128128
raise exc
129129

130-
cdef size_t _get_write_buffer_size(self):
130+
cdef size_t _get_write_buffer_size(self) noexcept:
131131
if self._handle is NULL:
132132
return 0
133133
return (<uv.uv_udp_t*>self._handle).send_queue_size
134134

135-
cdef bint _is_reading(self):
135+
cdef bint _is_reading(self) noexcept:
136136
return self.__receiving
137137

138138
cdef _start_reading(self):
@@ -309,7 +309,7 @@ cdef void __uv_udp_on_receive(uv.uv_udp_t* handle,
309309
ssize_t nread,
310310
const uv.uv_buf_t* buf,
311311
const system.sockaddr* addr,
312-
unsigned flags) with gil:
312+
unsigned flags) noexcept with gil:
313313

314314
if __ensure_handle_data(<uv.uv_handle_t*>handle,
315315
"UDPTransport receive callback") == 0:
@@ -375,7 +375,7 @@ cdef void __uv_udp_on_receive(uv.uv_udp_t* handle,
375375
udp._error(exc, False)
376376

377377

378-
cdef void __uv_udp_on_send(uv.uv_udp_send_t* req, int status) with gil:
378+
cdef void __uv_udp_on_send(uv.uv_udp_send_t* req, int status) noexcept with gil:
379379

380380
if req.data is NULL:
381381
# Shouldn't happen as:

uvloop/loop.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ cdef class Loop:
150150
cdef _call_later(self, uint64_t delay, object callback, object args,
151151
object context)
152152

153-
cdef void _handle_exception(self, object ex)
153+
cdef void _handle_exception(self, object ex) noexcept
154154

155155
cdef inline _is_main_thread(self)
156156

uvloop/loop.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ cdef class Loop:
681681
object context):
682682
return TimerHandle(self, callback, args, delay, context)
683683

684-
cdef void _handle_exception(self, object ex):
684+
cdef void _handle_exception(self, object ex) noexcept:
685685
if isinstance(ex, Exception):
686686
self.call_exception_handler({'exception': ex})
687687
else:
@@ -3232,7 +3232,7 @@ def libuv_get_version():
32323232

32333233
cdef void __loop_alloc_buffer(uv.uv_handle_t* uvhandle,
32343234
size_t suggested_size,
3235-
uv.uv_buf_t* buf) with gil:
3235+
uv.uv_buf_t* buf) noexcept with gil:
32363236
cdef:
32373237
Loop loop = (<UVHandle>uvhandle.data)._loop
32383238

@@ -3330,7 +3330,7 @@ cdef vint __forking = 0
33303330
cdef Loop __forking_loop = None
33313331

33323332

3333-
cdef void __get_fork_handler() nogil:
3333+
cdef void __get_fork_handler() noexcept nogil:
33343334
with gil:
33353335
if (__forking and __forking_loop is not None and
33363336
__forking_loop.active_process_handler is not None):

uvloop/sslproto.pxd

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ cdef class SSLProtocol:
122122
# Flow control for writes from APP socket
123123

124124
cdef _control_app_writing(self, object context=*)
125-
cdef size_t _get_write_buffer_size(self)
125+
cdef size_t _get_write_buffer_size(self) noexcept
126126
cdef _set_write_buffer_limits(self, high=*, low=*)
127127

128128
# Flow control for reads to APP socket
@@ -134,5 +134,5 @@ cdef class SSLProtocol:
134134

135135
cdef _control_ssl_reading(self)
136136
cdef _set_read_buffer_limits(self, high=*, low=*)
137-
cdef size_t _get_read_buffer_size(self)
137+
cdef size_t _get_read_buffer_size(self) noexcept
138138
cdef _fatal_error(self, exc, message=*)

0 commit comments

Comments
 (0)