fix: correctly fallback to pure python when cython is missing (#130)

This commit is contained in:
J. Nick Koston 2022-10-31 05:56:02 -05:00 committed by GitHub
parent 9cd85ad697
commit 8ab1f9d0b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -1,4 +1,12 @@
"""Stub for when Cython is not available."""
class FakeCython:
"""Stub for when Cython is not available."""
@property
def compiled(self):
def compiled(self) -> bool:
return False
FAKE_CYTHON = FakeCython()

View File

@ -142,7 +142,7 @@ class MarshallerStreamEndError(Exception):
try:
import cython
except ImportError:
from ._cython_compat import FakeCython as cython
from ._cython_compat import FAKE_CYTHON as cython
#
# Alignment padding is handled with the following formula below
@ -527,7 +527,7 @@ class Unmarshaller:
self._body_len = _cast_uint32_native(self._buf, 4) # pragma: no cover
self._serial = _cast_uint32_native(self._buf, 8) # pragma: no cover
self._header_len = _cast_uint32_native(self._buf, 12) # pragma: no cover
if endian == LITTLE_ENDIAN:
elif endian == LITTLE_ENDIAN:
(
self._body_len,
self._serial,