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

fix const-ness of some FFI name & doc members #3036

Merged
merged 1 commit into from
Mar 10, 2023
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/3036.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correct FFI definitions `PyGetSetDef`, `PyMemberDef`, `PyStructSequence_Field` and `PyStructSequence_Desc` to have `*const c_char` members for `name` and `doc` (not `*mut c_char`).
4 changes: 2 additions & 2 deletions pyo3-ffi/src/descrobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub type setter =
#[repr(C)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct PyGetSetDef {
pub name: *mut c_char,
pub name: *const c_char,
pub get: Option<getter>,
pub set: Option<setter>,
pub doc: *const c_char,
Expand All @@ -21,7 +21,7 @@ pub struct PyGetSetDef {
impl Default for PyGetSetDef {
fn default() -> PyGetSetDef {
PyGetSetDef {
name: ptr::null_mut(),
name: ptr::null(),
get: None,
set: None,
doc: ptr::null(),
Expand Down
4 changes: 2 additions & 2 deletions pyo3-ffi/src/structmember.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use std::ptr;
#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct PyMemberDef {
pub name: *mut c_char,
pub name: *const c_char,
pub type_code: c_int,
pub offset: Py_ssize_t,
pub flags: c_int,
pub doc: *mut c_char,
pub doc: *const c_char,
}

impl Default for PyMemberDef {
Expand Down
8 changes: 4 additions & 4 deletions pyo3-ffi/src/structseq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use std::os::raw::{c_char, c_int};
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyStructSequence_Field {
pub name: *mut c_char,
pub doc: *mut c_char,
pub name: *const c_char,
pub doc: *const c_char,
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyStructSequence_Desc {
pub name: *mut c_char,
pub doc: *mut c_char,
pub name: *const c_char,
pub doc: *const c_char,
pub fields: *mut PyStructSequence_Field,
pub n_in_sequence: c_int,
}
Expand Down