diff --git a/arrow/src/pyarrow.rs b/arrow/src/pyarrow.rs index 6061d7a75115..61b09769ac97 100644 --- a/arrow/src/pyarrow.rs +++ b/arrow/src/pyarrow.rs @@ -55,6 +55,7 @@ //! [pyarrow.Table.to_reader()](https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.to_reader) //! and then importing the reader as a [ArrowArrayStreamReader]. +use std::borrow::BorrowMut; use std::convert::{From, TryFrom}; use std::ptr::{addr_of, addr_of_mut}; use std::sync::Arc; @@ -262,9 +263,10 @@ impl FromPyArrow for ArrayData { validate_pycapsule(array_capsule, "arrow_array")?; let schema_ptr = unsafe { schema_capsule.reference::() }; - let array_ptr = unsafe { array_capsule.reference::() }; + let array_ptr = array_capsule.pointer() as *mut FFI_ArrowArray; + let array_mut = unsafe { array_ptr.as_mut() }; - let array = std::mem::replace(array_ptr, FFI_ArrowArray::empty()); + let array = std::mem::replace(array_mut.unwrap(), FFI_ArrowArray::empty()); return ffi::from_ffi(array, schema_ptr).map_err(to_py_err); }