Merge pull request #3251 from PyO3/addr_of
Fix two left-over usages of cfg(addr_of).
This commit is contained in:
commit
ed208731ed
|
@ -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);
|
||||
|
|
|
@ -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) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue