diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9cadbcc1..cc87bca5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -376,8 +376,8 @@ jobs: components: rust-src - name: Install python3 standalone debug build with nox run: | - PBS_RELEASE="20230826" - PBS_PYTHON_VERSION="3.11.5" + PBS_RELEASE="20231002" + PBS_PYTHON_VERSION="3.12.0" PBS_ARCHIVE="cpython-${PBS_PYTHON_VERSION}+${PBS_RELEASE}-x86_64-unknown-linux-gnu-debug-full.tar.zst" wget "https://github.com/indygreg/python-build-standalone/releases/download/${PBS_RELEASE}/${PBS_ARCHIVE}" tar -I zstd -xf "${PBS_ARCHIVE}" @@ -393,10 +393,10 @@ jobs: PYO3_CONFIG_FILE=$(mktemp) cat > $PYO3_CONFIG_FILE << EOF implementation=CPython - version=3.11 + version=3.12 shared=true abi3=false - lib_name=python3.11d + lib_name=python3.12d lib_dir=${{ github.workspace }}/python/install/lib executable=${{ github.workspace }}/python/install/bin/python3 pointer_width=64 diff --git a/pyo3-ffi/src/object.rs b/pyo3-ffi/src/object.rs index 0374ef26..1f3a1094 100644 --- a/pyo3-ffi/src/object.rs +++ b/pyo3-ffi/src/object.rs @@ -452,18 +452,14 @@ pub const Py_TPFLAGS_DEFAULT: c_ulong = if cfg!(Py_3_10) { pub const Py_TPFLAGS_HAVE_FINALIZE: c_ulong = 1; pub const Py_TPFLAGS_HAVE_VERSION_TAG: c_ulong = 1 << 18; -#[cfg(all(py_sys_config = "Py_REF_DEBUG", not(Py_LIMITED_API)))] extern "C" { - pub fn _Py_NegativeRefCount(filename: *const c_char, lineno: c_int, op: *mut PyObject); - #[cfg(Py_3_12)] - #[link_name = "_Py_IncRefTotal_DO_NOT_USE_THIS"] - fn _Py_INC_REFTOTAL(); - #[cfg(Py_3_12)] - #[link_name = "_Py_DecRefTotal_DO_NOT_USE_THIS"] - fn _Py_DEC_REFTOTAL(); -} + #[cfg(all(py_sys_config = "Py_REF_DEBUG", not(Py_LIMITED_API)))] + pub fn _Py_NegativeRefcount(filename: *const c_char, lineno: c_int, op: *mut PyObject); + #[cfg(all(Py_3_12, py_sys_config = "Py_REF_DEBUG", not(Py_LIMITED_API)))] + fn _Py_INCREF_IncRefTotal(); + #[cfg(all(Py_3_12, py_sys_config = "Py_REF_DEBUG", not(Py_LIMITED_API)))] + fn _Py_DECREF_DecRefTotal(); -extern "C" { #[cfg_attr(PyPy, link_name = "_PyPy_Dealloc")] pub fn _Py_Dealloc(arg1: *mut PyObject); @@ -537,7 +533,7 @@ pub unsafe fn Py_INCREF(op: *mut PyObject) { // or submit a PR supporting Py_STATS build option and pystats.h #[cfg(all(py_sys_config = "Py_REF_DEBUG", Py_3_12))] - _Py_INC_REFTOTAL(); + _Py_INCREF_IncRefTotal(); } } @@ -584,7 +580,7 @@ pub unsafe fn Py_DECREF(op: *mut PyObject) { // or submit a PR supporting Py_STATS build option and pystats.h #[cfg(all(py_sys_config = "Py_REF_DEBUG", Py_3_12))] - _Py_DEC_REFTOTAL(); + _Py_DECREF_DecRefTotal(); #[cfg(Py_3_12)] { @@ -593,7 +589,8 @@ pub unsafe fn Py_DECREF(op: *mut PyObject) { #[cfg(py_sys_config = "Py_REF_DEBUG")] if (*op).ob_refcnt.ob_refcnt < 0 { let location = std::panic::Location::caller(); - _Py_NegativeRefcount(location.file(), location.line(), op); + let filename = std::ffi::CString::new(location.file()).unwrap(); + _Py_NegativeRefcount(filename.as_ptr(), location.line() as i32, op); } if (*op).ob_refcnt.ob_refcnt == 0 {