From 52ff7fead1bcea5d3ad64fd28f37d89aeec27e8f Mon Sep 17 00:00:00 2001 From: Mattia Penati Date: Sat, 14 Feb 2026 12:00:05 +0100 Subject: [PATCH] Fix PyArray_DTypeMeta definition when Py_LIMITED_API is disabled --- CHANGELOG.md | 4 ++++ src/npyffi/objects.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35cc83368..8f9500f38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog + +- Unreleased + - Fix PyArray_DTypeMeta definition when Py_LIMITED_API is disabled (#532) + - v0.28.0 - Fix mismatched behavior between `PyArrayLike1` and `PyArrayLike2` when used with floats ([#520](https://github.com/PyO3/rust-numpy/pull/520)) - Add ownership-moving conversions into `PyReadonlyArray` and `PyReadwriteArray` ([#524](https://github.com/PyO3/rust-numpy/pull/524)) diff --git a/src/npyffi/objects.rs b/src/npyffi/objects.rs index d28e88b7e..4f4f1aaaf 100644 --- a/src/npyffi/objects.rs +++ b/src/npyffi/objects.rs @@ -549,6 +549,20 @@ pub struct PyArray_DatetimeDTypeMetaData { // https://github.com/rust-lang/rust/issues/43467 pub type npy_packed_static_string = c_void; pub type npy_string_allocator = c_void; + +#[cfg(not(Py_LIMITED_API))] +#[repr(C)] +pub struct PyArray_DTypeMeta { + pub superclass: PyHeapTypeObject, + pub singleton: *mut PyArray_Descr, + pub type_num: c_int, + pub scalar_type: *mut PyTypeObject, + pub flags: npy_uint64, + pub dt_slots: *mut c_void, + pub reserved: [*mut c_void; 3], +} + +#[cfg(Py_LIMITED_API)] pub type PyArray_DTypeMeta = PyTypeObject; #[repr(C)]