Merge pull request #3251 from PyO3/addr_of

Fix two left-over usages of cfg(addr_of).
This commit is contained in:
David Hewitt 2023-06-17 21:17:13 +00:00 committed by GitHub
commit ed208731ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 10 deletions

View File

@ -46,10 +46,7 @@ impl<T: PyTypeInfo> PyObjectInit<T> for PyNativeTypeInitializer<T> {
subtype: *mut PyTypeObject,
) -> PyResult<*mut ffi::PyObject> {
// HACK (due to FIXME below): PyBaseObject_Type's tp_new isn't happy with NULL arguments
#[cfg(addr_of)]
let is_base_object = type_object == std::ptr::addr_of_mut!(ffi::PyBaseObject_Type);
#[cfg(not(addr_of))]
let is_base_object = type_object == &mut ffi::PyBaseObject_Type as _;
if is_base_object {
let alloc = get_tp_alloc(subtype).unwrap_or(ffi::PyType_GenericAlloc);
let obj = alloc(subtype, 0);

View File

@ -189,13 +189,6 @@ macro_rules! pyobject_native_type_info(
#[inline]
fn type_object_raw(_py: $crate::Python<'_>) -> *mut $crate::ffi::PyTypeObject {
// Create a very short lived mutable reference and directly
// cast it to a pointer: no mutable references can be aliasing
// because we hold the GIL.
#[cfg(not(addr_of))]
unsafe { &mut $typeobject }
#[cfg(addr_of)]
unsafe { ::std::ptr::addr_of_mut!($typeobject) }
}