Skip to content

Commit 4b14d1d

Browse files
authored
Merge pull request #283 from PyO3/fix-limited-api
Drop the re-exports of PyMem_Raw* calls as those are not available using the limited API.
2 parents 2587fd9 + ea410ca commit 4b14d1d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

examples/simple/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ name = "rust_ext"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.16", features = ["extension-module"] }
12+
pyo3 = { version = "0.16", features = ["extension-module", "abi3-py37"] }
1313
numpy = { path = "../.." }

src/npyffi/array.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
//! Low-Level binding for [Array API](https://numpy.org/doc/stable/reference/c-api/array.html)
2-
use libc::FILE;
2+
//!
3+
//! Note that NumPy's low-level allocation functions `PyArray_{malloc,realloc,free}` are not part of this module.
4+
//! The reason is that they would be re-exports of the `PyMem_Raw{Malloc,Realloc,Free}` functions from PyO3,
5+
//! but those are not unconditionally exported, i.e. they are not available when using the limited Python C-API.
6+
37
use std::cell::Cell;
48
use std::os::raw::*;
59
use std::ptr::null;
610

11+
use libc::FILE;
712
use pyo3::ffi::{self, PyObject, PyTypeObject};
813

914
use crate::npyffi::*;
@@ -394,12 +399,6 @@ pub unsafe fn PyArray_CheckExact(py: Python, op: *mut PyObject) -> c_int {
394399
(ffi::Py_TYPE(op) == PY_ARRAY_API.get_type_object(py, NpyTypes::PyArray_Type)) as _
395400
}
396401

397-
// these are under `#if NPY_USE_PYMEM == 1` which seems to be always defined as 1
398-
pub use pyo3::ffi::{
399-
PyMem_RawFree as PyArray_free, PyMem_RawMalloc as PyArray_malloc,
400-
PyMem_RawRealloc as PyArray_realloc,
401-
};
402-
403402
#[cfg(test)]
404403
mod tests {
405404
use super::PY_ARRAY_API;

0 commit comments

Comments
 (0)