Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/6036.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove private FFI definitions `_PyFloat_CAST`, `_PyRun_SimpleFileObject`, `_PyRun_AnyFileObject`, `_PyRun_InteractiveLoopObject`, `_PyUnicode_CheckConsistency`, `_PyUnicode_COMPACT_DATA`, `_PyUnicode_NONCOMPACT_DATA`, `_PyUnicode_Ready`, and `_Py_HashBytes`.
14 changes: 0 additions & 14 deletions pyo3-ffi-check/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,6 @@ const EXCLUDED_SYMBOLS: &[&str] = &[
"_PyEval_RequestCodeExtraIndex",
// FIXME: probably outdated definitions that fail to build, need investigation,
// temporarily here to make the build pass to get CI running
"_PyFloat_CAST",
"_PyObject_MakeTpCall",
"_PyRun_AnyFileObject",
"_PyRun_InteractiveLoopObject",
"_PyRun_SimpleFileObject",
"_PySequence_IterSearch",
"_PySet_NextEntry",
"_PyUnicode_CheckConsistency",
"_Py_CheckFunctionResult",
"PyCode_New",
"PyCode_NewWithPosOnlyArgs",
"PyCFunction_New",
Expand All @@ -474,7 +465,6 @@ const EXCLUDED_SYMBOLS: &[&str] = &[
"PyUnicode_EncodeUnicodeEscape",
"PyUnicode_TransformDecimalToASCII",
"PyUnicode_TranslateCharmap",
"_Py_HashBytes",
// This symbol was not in headers but still public until Python 3.10,
// should be able to remove this exclusion once support for 3.9 dropped
"Py_GetArgcArgv",
Expand All @@ -491,10 +481,6 @@ const EXCLUDED_SYMBOLS: &[&str] = &[
"PyOS_BeforeFork",
"PyOS_AfterFork_Parent",
"PyOS_AfterFork_Child",
// Private symbols that pyo3-ffi should stop exporting
"_PyUnicode_COMPACT_DATA",
"_PyUnicode_NONCOMPACT_DATA",
"_PyUnicode_Ready",
// See https://github.com/python/cpython/pull/139166/changes#r3214904694
"Py_IS_TYPE",
"Py_SIZE",
Expand Down
7 changes: 5 additions & 2 deletions pyo3-ffi/src/cpython/floatobject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[cfg(GraalPy)]
use crate::PyFloat_AsDouble;
use crate::{PyFloat_Check, PyObject};
#[cfg(not(GraalPy))]
use crate::PyFloat_Check;
use crate::PyObject;
use core::ffi::c_double;

#[repr(C)]
Expand All @@ -10,7 +12,8 @@ pub struct PyFloatObject {
}

#[inline]
pub unsafe fn _PyFloat_CAST(op: *mut PyObject) -> *mut PyFloatObject {
#[cfg(not(GraalPy))]
unsafe fn _PyFloat_CAST(op: *mut PyObject) -> *mut PyFloatObject {
debug_assert_eq!(PyFloat_Check(op), 1);
op.cast()
}
Expand Down
21 changes: 0 additions & 21 deletions pyo3-ffi/src/cpython/pythonrun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,12 @@ use libc::FILE;

extern_libpython! {
pub fn PyRun_SimpleStringFlags(arg1: *const c_char, arg2: *mut PyCompilerFlags) -> c_int;
pub fn _PyRun_SimpleFileObject(
fp: *mut FILE,
filename: *mut PyObject,
closeit: c_int,
flags: *mut PyCompilerFlags,
) -> c_int;
pub fn PyRun_AnyFileExFlags(
fp: *mut FILE,
filename: *const c_char,
closeit: c_int,
flags: *mut PyCompilerFlags,
) -> c_int;
pub fn _PyRun_AnyFileObject(
fp: *mut FILE,
filename: *mut PyObject,
closeit: c_int,
flags: *mut PyCompilerFlags,
) -> c_int;
pub fn PyRun_SimpleFileExFlags(
fp: *mut FILE,
filename: *const c_char,
Expand All @@ -48,11 +36,6 @@ extern_libpython! {
filename: *const c_char,
flags: *mut PyCompilerFlags,
) -> c_int;
pub fn _PyRun_InteractiveLoopObject(
fp: *mut FILE,
filename: *mut PyObject,
flags: *mut PyCompilerFlags,
) -> c_int;

#[cfg(not(any(PyPy, GraalPy, Py_3_10)))]
pub fn PyParser_ASTFromString(
Expand Down Expand Up @@ -94,9 +77,7 @@ extern_libpython! {
errcode: *mut c_int,
arena: *mut PyArena,
) -> *mut _mod;
}

extern_libpython! {
#[cfg_attr(PyPy, link_name = "PyPyRun_StringFlags")]
pub fn PyRun_StringFlags(
arg1: *const c_char,
Expand Down Expand Up @@ -151,8 +132,6 @@ pub unsafe fn Py_CompileStringFlags(
Py_CompileStringExFlags(string, p, s, f, -1)
}

// skipped _Py_SourceAsString

extern_libpython! {
#[cfg_attr(PyPy, link_name = "PyPyRun_String")]
pub fn PyRun_String(
Expand Down
11 changes: 3 additions & 8 deletions pyo3-ffi/src/cpython/unicodeobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,6 @@ pub struct PyUnicodeObject {
pub data: PyUnicodeObjectData,
}

extern_libpython! {
#[cfg(not(any(PyPy, GraalPy)))]
pub fn _PyUnicode_CheckConsistency(op: *mut PyObject, check_content: c_int) -> c_int;
}

// skipped PyUnicode_GET_SIZE
// skipped PyUnicode_GET_DATA_SIZE
// skipped PyUnicode_AS_UNICODE
Expand Down Expand Up @@ -540,7 +535,7 @@ pub unsafe fn PyUnicode_KIND(op: *mut PyObject) -> c_uint {

#[cfg(not(any(GraalPy, Py_3_14)))]
#[inline]
pub unsafe fn _PyUnicode_COMPACT_DATA(op: *mut PyObject) -> *mut c_void {
unsafe fn _PyUnicode_COMPACT_DATA(op: *mut PyObject) -> *mut c_void {
if PyUnicode_IS_ASCII(op) != 0 {
(op as *mut PyASCIIObject).offset(1) as *mut c_void
} else {
Expand All @@ -550,7 +545,7 @@ pub unsafe fn _PyUnicode_COMPACT_DATA(op: *mut PyObject) -> *mut c_void {

#[cfg(not(any(GraalPy, PyPy)))]
#[inline]
pub unsafe fn _PyUnicode_NONCOMPACT_DATA(op: *mut PyObject) -> *mut c_void {
unsafe fn _PyUnicode_NONCOMPACT_DATA(op: *mut PyObject) -> *mut c_void {
debug_assert!(!(*(op as *mut PyUnicodeObject)).data.any.is_null());

(*(op as *mut PyUnicodeObject)).data.any
Expand Down Expand Up @@ -628,7 +623,7 @@ extern_libpython! {
#[cfg_attr(PyPy, link_name = "PyPyUnicode_New")]
pub fn PyUnicode_New(size: Py_ssize_t, maxchar: Py_UCS4) -> *mut PyObject;
#[cfg_attr(PyPy, link_name = "_PyPyUnicode_Ready")]
pub fn _PyUnicode_Ready(unicode: *mut PyObject) -> c_int;
fn _PyUnicode_Ready(unicode: *mut PyObject) -> c_int;

// skipped _PyUnicode_Copy

Expand Down
24 changes: 0 additions & 24 deletions pyo3-ffi/src/impl_/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,6 @@ macro_rules! extern_libpython_maybe_private_fn {
) => {
extern_libpython_cpython_private_fn! { $(#[$attrs])* $vis $name($($args)*) $(-> $ret)? }
};
(
[_PyRun_AnyFileObject]
$(#[$attrs:meta])* $vis:vis fn $name:ident($($args:tt)*) $(-> $ret:ty)?
) => {
extern_libpython_cpython_private_fn! { $(#[$attrs])* $vis $name($($args)*) $(-> $ret)? }
};
(
[_PyRun_InteractiveLoopObject]
$(#[$attrs:meta])* $vis:vis fn $name:ident($($args:tt)*) $(-> $ret:ty)?
) => {
extern_libpython_cpython_private_fn! { $(#[$attrs])* $vis $name($($args)*) $(-> $ret)? }
};
(
[_PyRun_SimpleFileObject]
$(#[$attrs:meta])* $vis:vis fn $name:ident($($args:tt)*) $(-> $ret:ty)?
) => {
extern_libpython_cpython_private_fn! { $(#[$attrs])* $vis $name($($args)*) $(-> $ret)? }
};
(
[_PyUnicode_CheckConsistency]
$(#[$attrs:meta])* $vis:vis fn $name:ident($($args:tt)*) $(-> $ret:ty)?
) => {
extern_libpython_cpython_private_fn! { $(#[$attrs])* $vis $name($($args)*) $(-> $ret)? }
};
(
[_PyUnicode_Ready]
$(#[$attrs:meta])* $vis:vis fn $name:ident($($args:tt)*) $(-> $ret:ty)?
Expand Down
8 changes: 4 additions & 4 deletions pyo3-ffi/src/pyhash.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
#[cfg(not(any(Py_LIMITED_API, PyPy, Py_3_14)))]
use crate::pyport::{Py_hash_t, Py_ssize_t};
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
#[cfg(not(any(Py_LIMITED_API, PyPy, Py_3_14)))]
use core::ffi::c_void;

use core::ffi::{c_int, c_ulong};
Expand All @@ -10,8 +10,8 @@ extern_libpython! {
// skipped non-limited _Py_HashPointer
// skipped non-limited _Py_HashPointerRaw

#[cfg(not(any(Py_LIMITED_API, PyPy)))]
pub fn _Py_HashBytes(src: *const c_void, len: Py_ssize_t) -> Py_hash_t;
#[cfg(not(any(Py_LIMITED_API, PyPy, Py_3_14)))]
pub(crate) fn _Py_HashBytes(src: *const c_void, len: Py_ssize_t) -> Py_hash_t;
}

pub const _PyHASH_MULTIPLIER: c_ulong = 1000003;
Expand Down
Loading