Skip to content

Commit

Permalink
corrections from review
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Jul 30, 2023
1 parent ea4cf62 commit 95108e2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pyo3-ffi/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub const PyObject_HEAD_INIT: PyObject = PyObject {
#[cfg(py_sys_config = "Py_TRACE_REFS")]
_ob_prev: std::ptr::null_mut(),
#[cfg(Py_3_12)]
ob_refcnt: __pyo3_object_ob_refcnt { ob_refcnt: 1 },
ob_refcnt: PyObjectObRefcnt { ob_refcnt: 1 },
#[cfg(not(Py_3_12))]
ob_refcnt: 1,
#[cfg(PyPy)]
Expand All @@ -42,21 +42,23 @@ pub const PyObject_HEAD_INIT: PyObject = PyObject {
#[repr(C)]
#[derive(Copy, Clone)]
#[cfg(Py_3_12)]
pub union __pyo3_object_ob_refcnt {
/// This union is anonymous in CPython, so the name was given by PyO3 because
/// Rust unions need a name.
pub union PyObjectObRefcnt {
pub ob_refcnt: Py_ssize_t,
#[cfg(not(target_pointer_width = "32"))]
pub ob_refcnt_split: [crate::PY_UINT32_T; 2],
}

#[cfg(Py_3_12)]
impl std::fmt::Debug for __pyo3_object_ob_refcnt {
impl std::fmt::Debug for PyObjectObRefcnt {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", unsafe { self.ob_refcnt })
}
}

#[cfg(not(Py_3_12))]
pub type __pyo3_object_ob_refcnt = Py_ssize_t;
pub type PyObjectObRefcnt = Py_ssize_t;

#[repr(C)]
#[derive(Copy, Clone, Debug)]
Expand All @@ -65,7 +67,7 @@ pub struct PyObject {
pub _ob_next: *mut PyObject,
#[cfg(py_sys_config = "Py_TRACE_REFS")]
pub _ob_prev: *mut PyObject,
pub ob_refcnt: __pyo3_object_ob_refcnt,
pub ob_refcnt: PyObjectObRefcnt,
#[cfg(PyPy)]
pub ob_pypy_link: Py_ssize_t,
pub ob_type: *mut PyTypeObject,
Expand Down Expand Up @@ -383,7 +385,7 @@ pub const _Py_TPFLAGS_STATIC_BUILTIN: c_ulong = 1 << 1;
pub const Py_TPFLAGS_MANAGED_WEAKREF: c_ulong = 1 << 3;

#[cfg(all(Py_3_11, not(Py_LIMITED_API)))]
pub const Py_TPFLAGS_MANAGED_DICT: c_ulong = 1 << 3;
pub const Py_TPFLAGS_MANAGED_DICT: c_ulong = 1 << 4;

#[cfg(all(Py_3_10, not(Py_LIMITED_API)))]
pub const Py_TPFLAGS_SEQUENCE: c_ulong = 1 << 5;
Expand Down

0 comments on commit 95108e2

Please sign in to comment.