Skip to content
Open
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/5824.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate and remove `Py_TRACE_REFS` support (unsupported from Python 3.13).
5 changes: 2 additions & 3 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ pub fn cross_compiling_from_cargo_env() -> Result<Option<CrossCompileConfig>> {
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,
Expand All @@ -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())),
Expand All @@ -1194,10 +1194,9 @@ impl FromStr for BuildFlag {
pub struct BuildFlags(pub HashSet<BuildFlag>);

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,
];
Expand Down
27 changes: 1 addition & 26 deletions pyo3-ffi/src/modsupport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -101,39 +101,14 @@ 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,
spec: *mut PyObject,
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]
Expand Down
8 changes: 0 additions & 8 deletions pyo3-ffi/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))]
Expand Down Expand Up @@ -128,10 +124,6 @@ const _: () = assert!(std::mem::align_of::<PyObject>() >= _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))]
Expand Down
Loading