From 8ab1f9d0b380293294a0f847664e0c459061c2d9 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 31 Oct 2022 05:56:02 -0500 Subject: [PATCH] fix: correctly fallback to pure python when cython is missing (#130) --- src/dbus_fast/_private/_cython_compat.py | 10 +++++++++- src/dbus_fast/_private/unmarshaller.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/dbus_fast/_private/_cython_compat.py b/src/dbus_fast/_private/_cython_compat.py index 44756e1..27c9626 100644 --- a/src/dbus_fast/_private/_cython_compat.py +++ b/src/dbus_fast/_private/_cython_compat.py @@ -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() diff --git a/src/dbus_fast/_private/unmarshaller.py b/src/dbus_fast/_private/unmarshaller.py index 7083277..4fcaa27 100644 --- a/src/dbus_fast/_private/unmarshaller.py +++ b/src/dbus_fast/_private/unmarshaller.py @@ -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,