From 52e74bac8673fdec28c305cb03f6b22dfc93089c Mon Sep 17 00:00:00 2001 From: jakirkham Date: Fri, 15 Nov 2024 20:50:06 -0800 Subject: [PATCH 1/3] Add `noexcept` to `_utils` C-equiv functions The functions in `_utils` are effectively straight C functions. In Cython 0.x, these would have been treated as `noexcept` by default. However in Cython 3.x all functions are treated as potentially raising exceptions (including these). While that is a sensible default in general, these functions still won't raise exceptions. So tidy things up by adding `noexcept` to turn off the additional Cython checks emitted in and around them. --- docs/release.rst | 6 ++++++ numcodecs/_utils.pxd | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/release.rst b/docs/release.rst index 4270ce27..58ba95ff 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -11,6 +11,12 @@ Release notes Unreleased ---------- +Fix +~~~ + +* Add `noexcept` to `_utils` C-equiv functions + By :user:`John Kirkham `, :issue:`641`. + .. _release_0.14.0: diff --git a/numcodecs/_utils.pxd b/numcodecs/_utils.pxd index c2614e12..296112b3 100644 --- a/numcodecs/_utils.pxd +++ b/numcodecs/_utils.pxd @@ -8,14 +8,14 @@ from libc.stdint cimport uint8_t, uint32_t -cdef inline void store_le32(uint8_t c[4], uint32_t i) nogil: +cdef inline void store_le32(uint8_t c[4], uint32_t i) nogil noexcept: c[0] = i & 0xFF c[1] = (i >> 8) & 0xFF c[2] = (i >> 16) & 0xFF c[3] = (i >> 24) & 0xFF -cdef inline uint32_t load_le32(const uint8_t c[4]) nogil: +cdef inline uint32_t load_le32(const uint8_t c[4]) nogil noexcept: return ( c[0] | (c[1] << 8) | From 16556ff9f9d10d3749b0973c38d8034d9282f880 Mon Sep 17 00:00:00 2001 From: jakirkham Date: Mon, 18 Nov 2024 00:04:26 -0800 Subject: [PATCH 2/3] Swap order of `nogil` & `noexcept` Fixes a Cython warning when using the opposite ordering. --- numcodecs/_utils.pxd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numcodecs/_utils.pxd b/numcodecs/_utils.pxd index 296112b3..c76f3e18 100644 --- a/numcodecs/_utils.pxd +++ b/numcodecs/_utils.pxd @@ -8,14 +8,14 @@ from libc.stdint cimport uint8_t, uint32_t -cdef inline void store_le32(uint8_t c[4], uint32_t i) nogil noexcept: +cdef inline void store_le32(uint8_t c[4], uint32_t i) noexcept nogil: c[0] = i & 0xFF c[1] = (i >> 8) & 0xFF c[2] = (i >> 16) & 0xFF c[3] = (i >> 24) & 0xFF -cdef inline uint32_t load_le32(const uint8_t c[4]) nogil noexcept: +cdef inline uint32_t load_le32(const uint8_t c[4]) noexcept nogil: return ( c[0] | (c[1] << 8) | From 83b8095174015f69c7fa422545a50a54434965f6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:39:33 +0000 Subject: [PATCH 3/3] style: pre-commit fixes --- docs/release.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release.rst b/docs/release.rst index 4c4a27de..5d64406f 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -15,7 +15,7 @@ Fixes ~~~~~ * Cleanup ``crc32c`` soft dependency. By :user:`John Kirkham `, :issue:`637` - + Improvements ~~~~~~~~~~~~ * Add `noexcept` to `_utils` C-equiv functions