Skip to content

Commit 0043caa

Browse files
committed
Improve function signatures for exception handling in recent Cython versions.
1 parent 5c74fe5 commit 0043caa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

fastrlock/_lock.pxi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cdef struct _LockStatus:
2929

3030

3131
cdef bint _acquire_lock(_LockStatus *lock, long current_thread,
32-
bint blocking) nogil:
32+
bint blocking) nogil except -1:
3333
# Note that this function *must* hold the GIL when being called.
3434
# We just use 'nogil' in the signature to make sure that no Python
3535
# code execution slips in that might free the GIL
@@ -62,7 +62,7 @@ cdef bint _acquire_lock(_LockStatus *lock, long current_thread,
6262
return True
6363

6464

65-
cdef inline void _unlock_lock(_LockStatus *lock) nogil:
65+
cdef inline void _unlock_lock(_LockStatus *lock) nogil noexcept:
6666
# Note that this function *must* hold the GIL when being called.
6767
# We just use 'nogil' in the signature to make sure that no Python
6868
# code execution slips in that might free the GIL

fastrlock/rlock.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cdef class FastRLock:
5757

5858

5959
cdef inline bint _lock_rlock(_LockStatus *lock, pythread_t current_thread,
60-
bint blocking) nogil:
60+
bint blocking) nogil except -1:
6161
# Note that this function *must* hold the GIL when being called.
6262
# We just use 'nogil' in the signature to make sure that no Python
6363
# code execution slips in that might free the GIL
@@ -66,12 +66,12 @@ cdef inline bint _lock_rlock(_LockStatus *lock, pythread_t current_thread,
6666
# locked! - by myself?
6767
if lock.owner == current_thread:
6868
lock.entry_count += 1
69-
return 1
69+
return True
7070
elif not lock.pending_requests:
7171
# not locked, not requested - go!
7272
lock.owner = current_thread
7373
lock.entry_count = 1
74-
return 1
74+
return True
7575
# need to get the real lock
7676
return _acquire_lock(lock, current_thread, blocking)
7777

@@ -89,7 +89,7 @@ cdef create_fastrlock():
8989
cdef bint lock_fastrlock(rlock, long current_thread, bint blocking) except -1:
9090
"""
9191
Public C level entry function for locking a FastRlock instance.
92-
92+
9393
The 'current_thread' argument is deprecated and ignored. Pass -1 for backwards compatibility.
9494
"""
9595
# Note: 'current_thread' used to be set to -1 or the current thread ID, but -1 is signed while "pythread_t" isn't.

0 commit comments

Comments
 (0)