diff --git a/newsfragments/5824.changed.md b/newsfragments/5824.changed.md new file mode 100644 index 00000000000..3bcfc0afda2 --- /dev/null +++ b/newsfragments/5824.changed.md @@ -0,0 +1 @@ +Deprecate and remove `Py_TRACE_REFS` support (unsupported from Python 3.13). \ No newline at end of file diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index 167013f5c42..a2e04c00df2 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -1147,6 +1147,7 @@ pub fn cross_compiling_from_cargo_env() -> Result> { pub enum BuildFlag { Py_DEBUG, Py_REF_DEBUG, + #[deprecated(since = "0.29.0", note = "no longer supported by PyO3")] Py_TRACE_REFS, Py_GIL_DISABLED, COUNT_ALLOCS, @@ -1168,7 +1169,6 @@ impl FromStr for BuildFlag { match s { "Py_DEBUG" => Ok(BuildFlag::Py_DEBUG), "Py_REF_DEBUG" => Ok(BuildFlag::Py_REF_DEBUG), - "Py_TRACE_REFS" => Ok(BuildFlag::Py_TRACE_REFS), "Py_GIL_DISABLED" => Ok(BuildFlag::Py_GIL_DISABLED), "COUNT_ALLOCS" => Ok(BuildFlag::COUNT_ALLOCS), other => Ok(BuildFlag::Other(other.to_owned())), @@ -1194,10 +1194,9 @@ impl FromStr for BuildFlag { pub struct BuildFlags(pub HashSet); impl BuildFlags { - const ALL: [BuildFlag; 5] = [ + const ALL: [BuildFlag; 4] = [ BuildFlag::Py_DEBUG, BuildFlag::Py_REF_DEBUG, - BuildFlag::Py_TRACE_REFS, BuildFlag::Py_GIL_DISABLED, BuildFlag::COUNT_ALLOCS, ]; diff --git a/pyo3-ffi/src/modsupport.rs b/pyo3-ffi/src/modsupport.rs index b6186ddc8bc..e3dd1f2ee7c 100644 --- a/pyo3-ffi/src/modsupport.rs +++ b/pyo3-ffi/src/modsupport.rs @@ -83,7 +83,7 @@ pub const PYTHON_API_VERSION: i32 = 1013; pub const PYTHON_ABI_VERSION: i32 = 3; extern "C" { - #[cfg(not(py_sys_config = "Py_TRACE_REFS"))] + #[cfg_attr(PyPy, link_name = "PyPyModule_Create2")] pub fn PyModule_Create2(module: *mut PyModuleDef, apiver: c_int) -> *mut PyObject; } @@ -101,10 +101,7 @@ pub unsafe fn PyModule_Create(module: *mut PyModuleDef) -> *mut PyObject { } extern "C" { - #[cfg(py_sys_config = "Py_TRACE_REFS")] - fn PyModule_Create2TraceRefs(module: *mut PyModuleDef, apiver: c_int) -> *mut PyObject; - #[cfg(not(py_sys_config = "Py_TRACE_REFS"))] #[cfg_attr(PyPy, link_name = "PyPyModule_FromDefAndSpec2")] pub fn PyModule_FromDefAndSpec2( def: *mut PyModuleDef, @@ -112,28 +109,6 @@ extern "C" { module_api_version: c_int, ) -> *mut PyObject; - #[cfg(py_sys_config = "Py_TRACE_REFS")] - fn PyModule_FromDefAndSpec2TraceRefs( - def: *mut PyModuleDef, - spec: *mut PyObject, - module_api_version: c_int, - ) -> *mut PyObject; -} - -#[cfg(py_sys_config = "Py_TRACE_REFS")] -#[inline] -pub unsafe fn PyModule_Create2(module: *mut PyModuleDef, apiver: c_int) -> *mut PyObject { - PyModule_Create2TraceRefs(module, apiver) -} - -#[cfg(py_sys_config = "Py_TRACE_REFS")] -#[inline] -pub unsafe fn PyModule_FromDefAndSpec2( - def: *mut PyModuleDef, - spec: *mut PyObject, - module_api_version: c_int, -) -> *mut PyObject { - PyModule_FromDefAndSpec2TraceRefs(def, spec, module_api_version) } #[inline] diff --git a/pyo3-ffi/src/object.rs b/pyo3-ffi/src/object.rs index ddeabb9be3f..a6fc6d39ff6 100644 --- a/pyo3-ffi/src/object.rs +++ b/pyo3-ffi/src/object.rs @@ -96,10 +96,6 @@ const _PyObject_MIN_ALIGNMENT: usize = 4; #[cfg_attr(all(Py_3_15, Py_GIL_DISABLED), repr(C, align(4)))] #[derive(Debug)] pub struct PyObject { - #[cfg(py_sys_config = "Py_TRACE_REFS")] - pub _ob_next: *mut PyObject, - #[cfg(py_sys_config = "Py_TRACE_REFS")] - pub _ob_prev: *mut PyObject, #[cfg(Py_GIL_DISABLED)] pub ob_tid: libc::uintptr_t, #[cfg(all(Py_GIL_DISABLED, not(Py_3_14)))] @@ -128,10 +124,6 @@ const _: () = assert!(std::mem::align_of::() >= _PyObject_MIN_ALIGNMEN reason = "contains atomic refcount on free-threaded builds" )] pub const PyObject_HEAD_INIT: PyObject = PyObject { - #[cfg(py_sys_config = "Py_TRACE_REFS")] - _ob_next: std::ptr::null_mut(), - #[cfg(py_sys_config = "Py_TRACE_REFS")] - _ob_prev: std::ptr::null_mut(), #[cfg(Py_GIL_DISABLED)] ob_tid: 0, #[cfg(all(Py_GIL_DISABLED, Py_3_15))]