Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ffi structures for PyPy 7.3.15 #3757

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/3757.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Match PyPy 7.3.14 in removing PyPy-only symbol `Py_MAX_NDIMS` in favour of `PyBUF_MAX_NDIM`.
13 changes: 5 additions & 8 deletions pyo3-ffi/src/cpython/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ mod bufferinfo {
use std::os::raw::{c_char, c_int, c_void};
use std::ptr;

#[cfg(PyPy)]
const Py_MAX_NDIMS: usize = if cfg!(Py_3_9) { 64 } else { 36 };

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Py_buffer {
Expand All @@ -43,9 +40,9 @@ mod bufferinfo {
#[cfg(PyPy)]
pub flags: c_int,
#[cfg(PyPy)]
pub _strides: [Py_ssize_t; Py_MAX_NDIMS],
pub _strides: [Py_ssize_t; PyBUF_MAX_NDIM as usize],
#[cfg(PyPy)]
pub _shape: [Py_ssize_t; Py_MAX_NDIMS],
pub _shape: [Py_ssize_t; PyBUF_MAX_NDIM as usize],
}

impl Py_buffer {
Expand All @@ -65,9 +62,9 @@ mod bufferinfo {
#[cfg(PyPy)]
flags: 0,
#[cfg(PyPy)]
_strides: [0; Py_MAX_NDIMS],
_strides: [0; PyBUF_MAX_NDIM as usize],
#[cfg(PyPy)]
_shape: [0; Py_MAX_NDIMS],
_shape: [0; PyBUF_MAX_NDIM as usize],
}
}
}
Expand All @@ -81,7 +78,7 @@ mod bufferinfo {
unsafe extern "C" fn(arg1: *mut crate::PyObject, arg2: *mut Py_buffer);

/// Maximum number of dimensions
pub const PyBUF_MAX_NDIM: c_int = 64;
pub const PyBUF_MAX_NDIM: c_int = if cfg!(PyPy) { 36 } else { 64 };

/* Flags for getting buffers */
pub const PyBUF_SIMPLE: c_int = 0;
Expand Down
13 changes: 5 additions & 8 deletions pyo3-ffi/src/pybuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int, c_void};
use std::ptr;

#[cfg(PyPy)]
const Py_MAX_NDIMS: usize = 36;

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Py_buffer {
Expand All @@ -24,9 +21,9 @@ pub struct Py_buffer {
#[cfg(PyPy)]
pub flags: c_int,
#[cfg(PyPy)]
pub _strides: [Py_ssize_t; Py_MAX_NDIMS],
pub _strides: [Py_ssize_t; PyBUF_MAX_NDIM],
#[cfg(PyPy)]
pub _shape: [Py_ssize_t; Py_MAX_NDIMS],
pub _shape: [Py_ssize_t; PyBUF_MAX_NDIM],
}

impl Py_buffer {
Expand All @@ -46,9 +43,9 @@ impl Py_buffer {
#[cfg(PyPy)]
flags: 0,
#[cfg(PyPy)]
_strides: [0; Py_MAX_NDIMS],
_strides: [0; PyBUF_MAX_NDIM],
#[cfg(PyPy)]
_shape: [0; Py_MAX_NDIMS],
_shape: [0; PyBUF_MAX_NDIM],
}
}
}
Expand Down Expand Up @@ -105,7 +102,7 @@ extern "C" {
}

/// Maximum number of dimensions
pub const PyBUF_MAX_NDIM: c_int = 64;
pub const PyBUF_MAX_NDIM: c_int = if cfg!(PyPy) { 36 } else { 64 };

/* Flags for getting buffers */
pub const PyBUF_SIMPLE: c_int = 0;
Expand Down