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/5105.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove FFI definitions of private static variables: `_PyMethodWrapper_Type`, `_PyCoroWrapper_Type`, `_PyImport_FrozenBootstrap`, `_PyImport_FrozenStdlib`, `_PyImport_FrozenTest`, `_PyManagedBuffer_Type`, `_PySet_Dummy`, `_PyWeakref_ProxyType`, and `_PyWeakref_CallableProxyType`.
5 changes: 1 addition & 4 deletions pyo3-ffi/src/cpython/descrobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ pub struct PyWrapperDescrObject {
pub d_wrapped: *mut c_void,
}

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
pub static mut _PyMethodWrapper_Type: PyTypeObject;
}
// skipped _PyMethodWrapper_Type

// skipped non-limited PyDescr_NewWrapper
// skipped non-limited PyDescr_IsData
3 changes: 2 additions & 1 deletion pyo3-ffi/src/cpython/genobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ extern "C" {
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
pub static mut PyCoro_Type: PyTypeObject;
pub static mut _PyCoroWrapper_Type: PyTypeObject;
}

// skipped _PyCoroWrapper_Type

#[inline]
pub unsafe fn PyCoro_CheckExact(op: *mut PyObject) -> c_int {
PyObject_TypeCheck(op, addr_of_mut!(PyCoro_Type))
Expand Down
10 changes: 4 additions & 6 deletions pyo3-ffi/src/cpython/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ pub struct _frozen {
extern "C" {
#[cfg(not(PyPy))]
pub static mut PyImport_FrozenModules: *const _frozen;
#[cfg(all(not(PyPy), Py_3_11))]
pub static mut _PyImport_FrozenBootstrap: *const _frozen;
#[cfg(all(not(PyPy), Py_3_11))]
pub static mut _PyImport_FrozenStdlib: *const _frozen;
#[cfg(all(not(PyPy), Py_3_11))]
pub static mut _PyImport_FrozenTest: *const _frozen;
}

// skipped _PyImport_FrozenBootstrap
// skipped _PyImport_FrozenStdlib
// skipped _PyImport_FrozenTest
5 changes: 2 additions & 3 deletions pyo3-ffi/src/memoryobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int};
use std::ptr::addr_of_mut;

// skipped _PyManagedBuffer_Type

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
#[cfg(not(Py_LIMITED_API))]
pub static mut _PyManagedBuffer_Type: PyTypeObject;

#[cfg_attr(PyPy, link_name = "PyPyMemoryView_Type")]
pub static mut PyMemoryView_Type: PyTypeObject;
}
Expand Down
6 changes: 1 addition & 5 deletions pyo3-ffi/src/setobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ pub unsafe fn PySet_GET_SIZE(so: *mut PyObject) -> Py_ssize_t {
(*so).used
}

#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
pub static mut _PySet_Dummy: *mut PyObject;
}
// skipped _PySet_Dummy

extern "C" {
#[cfg(not(Py_LIMITED_API))]
Expand Down
6 changes: 4 additions & 2 deletions pyo3-ffi/src/weakrefobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ pub use crate::_PyWeakReference as PyWeakReference;

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
// TODO: PyO3 is depending on this symbol in `reference.rs`, we should change this and
// remove the export as this is a private symbol.
pub static mut _PyWeakref_RefType: PyTypeObject;
pub static mut _PyWeakref_ProxyType: PyTypeObject;
pub static mut _PyWeakref_CallableProxyType: PyTypeObject;
static mut _PyWeakref_ProxyType: PyTypeObject;
static mut _PyWeakref_CallableProxyType: PyTypeObject;

#[cfg(PyPy)]
#[link_name = "PyPyWeakref_CheckRef"]
Expand Down
1 change: 1 addition & 0 deletions src/types/weakref/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pyobject_subclassable_native_type!(PyWeakrefReference, crate::ffi::PyWeakReferen
pyobject_native_type!(
PyWeakrefReference,
ffi::PyWeakReference,
// TODO: should not be depending on a private symbol here!
pyobject_native_static_type_object!(ffi::_PyWeakref_RefType),
#module=Some("weakref"),
#checkfunction=ffi::PyWeakref_CheckRefExact
Expand Down
Loading