From 8c16e1ca90e62b582eb0815baf5a97b6348e69d3 Mon Sep 17 00:00:00 2001 From: chiri Date: Sat, 2 May 2026 17:30:13 +0300 Subject: [PATCH 1/2] `std::os::raw::*` -> `std::ffi::*` --- pyo3-ffi/src/cpython/lock.rs | 2 +- pyo3-macros-backend/src/module.rs | 2 +- src/impl_/callback.rs | 2 +- src/impl_/pyclass.rs | 2 +- src/impl_/pymodule.rs | 4 ++-- src/impl_/trampoline.rs | 2 +- src/pyclass.rs | 2 +- src/pyclass/create_type_object.rs | 2 +- src/pyclass/gc.rs | 2 +- tests/test_buffer.rs | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyo3-ffi/src/cpython/lock.rs b/pyo3-ffi/src/cpython/lock.rs index 3ad4f50edb0..2565e40534f 100644 --- a/pyo3-ffi/src/cpython/lock.rs +++ b/pyo3-ffi/src/cpython/lock.rs @@ -1,5 +1,5 @@ #[cfg(Py_3_14)] -use std::os::raw::c_int; +use std::ffi::c_int; use std::sync::atomic::AtomicU8; #[repr(transparent)] diff --git a/pyo3-macros-backend/src/module.rs b/pyo3-macros-backend/src/module.rs index b3a127a4ba5..6f766523711 100644 --- a/pyo3-macros-backend/src/module.rs +++ b/pyo3-macros-backend/src/module.rs @@ -540,7 +540,7 @@ fn module_initialization( pub static _PYO3_DEF: #pyo3_path::impl_::pymodule::ModuleDef = { use #pyo3_path::impl_::pymodule as impl_; - unsafe extern "C" fn __pyo3_module_exec(module: *mut #pyo3_path::ffi::PyObject) -> ::std::os::raw::c_int { + unsafe extern "C" fn __pyo3_module_exec(module: *mut #pyo3_path::ffi::PyObject) -> ::std::ffi::c_int { #pyo3_path::impl_::trampoline::module_exec(module, #module_exec) } diff --git a/src/impl_/callback.rs b/src/impl_/callback.rs index cb2ec012338..f21f8e2f3d7 100644 --- a/src/impl_/callback.rs +++ b/src/impl_/callback.rs @@ -14,7 +14,7 @@ pub trait PyCallbackOutput: Copy + py_callback_output::Sealed { /// Seals `PyCallbackOutput` so that types outside PyO3 cannot implement it. mod py_callback_output { - use std::os::raw::c_int; + use std::ffi::c_int; use pyo3_ffi::Py_ssize_t; diff --git a/src/impl_/pyclass.rs b/src/impl_/pyclass.rs index eff4be274d5..b20e65945c0 100644 --- a/src/impl_/pyclass.rs +++ b/src/impl_/pyclass.rs @@ -15,8 +15,8 @@ use crate::{ }; use std::{ ffi::CStr, + ffi::{c_int, c_void}, marker::PhantomData, - os::raw::{c_int, c_void}, ptr::{self, NonNull}, sync::Mutex, thread, diff --git a/src/impl_/pymodule.rs b/src/impl_/pymodule.rs index 4a99b1b6fb9..d0a32881b6c 100644 --- a/src/impl_/pymodule.rs +++ b/src/impl_/pymodule.rs @@ -3,8 +3,8 @@ use std::{ cell::UnsafeCell, ffi::CStr, + ffi::{c_int, c_void}, marker::PhantomData, - os::raw::{c_int, c_void}, }; #[cfg(all( @@ -418,7 +418,7 @@ impl PyAddToModule for ModuleDef { #[cfg(test)] mod tests { - use std::{borrow::Cow, ffi::CStr, os::raw::c_int}; + use std::{borrow::Cow, ffi::c_int, ffi::CStr}; use crate::{ ffi, diff --git a/src/impl_/trampoline.rs b/src/impl_/trampoline.rs index 8bd82bfa91e..c184335d302 100644 --- a/src/impl_/trampoline.rs +++ b/src/impl_/trampoline.rs @@ -7,7 +7,7 @@ use std::{ any::Any, - os::raw::c_int, + ffi::c_int, panic::{self, UnwindSafe}, }; diff --git a/src/pyclass.rs b/src/pyclass.rs index e68932bc55a..cd2fb1e4b83 100644 --- a/src/pyclass.rs +++ b/src/pyclass.rs @@ -1,6 +1,6 @@ //! `PyClass` and related traits. use crate::{ffi, impl_::pyclass::PyClassImpl, PyTypeInfo}; -use std::{cmp::Ordering, os::raw::c_int}; +use std::{cmp::Ordering, ffi::c_int}; mod create_type_object; mod gc; diff --git a/src/pyclass/create_type_object.rs b/src/pyclass/create_type_object.rs index 063b615c8a4..f417df75f42 100644 --- a/src/pyclass/create_type_object.rs +++ b/src/pyclass/create_type_object.rs @@ -20,8 +20,8 @@ use crate::{ }; use std::{ collections::HashMap, + ffi::{c_char, c_int, c_ulong, c_void}, ffi::{CStr, CString}, - os::raw::{c_char, c_int, c_ulong, c_void}, ptr::{self, NonNull}, }; diff --git a/src/pyclass/gc.rs b/src/pyclass/gc.rs index 6b9da449c3e..0b404a0f034 100644 --- a/src/pyclass/gc.rs +++ b/src/pyclass/gc.rs @@ -1,7 +1,7 @@ use std::{ + ffi::{c_int, c_void}, marker::PhantomData, num::NonZero, - os::raw::{c_int, c_void}, }; use crate::{ffi, Py}; diff --git a/tests/test_buffer.rs b/tests/test_buffer.rs index 5e66e67ab3a..cfec7e149bb 100644 --- a/tests/test_buffer.rs +++ b/tests/test_buffer.rs @@ -4,7 +4,7 @@ use pyo3::{buffer::PyBuffer, exceptions::PyBufferError, ffi, prelude::*}; use std::{ - os::raw::{c_int, c_void}, + ffi::{c_int, c_void}, ptr, }; From 3a491a8c5ccc0d143e94bca1734cf98370783f09 Mon Sep 17 00:00:00 2001 From: chiri Date: Sat, 2 May 2026 17:36:03 +0300 Subject: [PATCH 2/2] add .md file --- newsfragments/6013.changed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/6013.changed.md diff --git a/newsfragments/6013.changed.md b/newsfragments/6013.changed.md new file mode 100644 index 00000000000..05fa3aae235 --- /dev/null +++ b/newsfragments/6013.changed.md @@ -0,0 +1 @@ +Use `std::ffi` C type aliases instead of `std::os::raw` aliases internally. \ No newline at end of file