Skip to content

Commit b8109fb

Browse files
authored
Work around a recent Cython bug. (#29)
I'll be sending a fix upstream also but I want to move things forward on our side without waiting for a Cython release.
1 parent 780c522 commit b8109fb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: uuid.pyx

+7-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,13 @@ cdef class UUID(__UUIDReplaceMe):
172172
if self._int is None:
173173
# The cache is important because `self.int` can be
174174
# used multiple times by __hash__ etc.
175-
self._int = int.from_bytes(self.bytes, 'big')
175+
#
176+
# The or 0 works around a bug interaction between cpython
177+
# 3.10 and earlier and Cython ~3.0.11 in which
178+
# int.from_bytes returns a "non-canonical 0" and then
179+
# Cython's implementation of & mishandles it.
180+
# See cython/cython#6480.
181+
self._int = int.from_bytes(self.bytes, 'big') or 0
176182
return self._int
177183

178184
@property

0 commit comments

Comments
 (0)