Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion a_sync/primitives/locks/semaphore.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ cdef class Semaphore(_DebugDaemonMixin):
) from e.__cause__

# we need a constant to coerce to char*
cdef bytes encoded_name = (name or getattr(self, "__origin__", "")).encode("utf-8")
cdef bytes encoded_name
try:
encoded_name = (name or getattr(self, "__origin__", "")).encode("utf-8")
except SystemError as e:
if str(e) == "bad argument to internal function":
# This can happen if Semaphore is subclassed in a mypyc extension module due to conflict with getattr. No problem.
encoded_name = b""
else:
raise

cdef Py_ssize_t length = len(encoded_name)

# Allocate memory for the char* and add 1 for the null character
Expand Down
Loading