diff --git a/vm/src/protocol/buffer.rs b/vm/src/protocol/buffer.rs index 48985330a2..4af99b032d 100644 --- a/vm/src/protocol/buffer.rs +++ b/vm/src/protocol/buffer.rs @@ -108,7 +108,7 @@ impl TryFromBorrowedObject for PyBuffer { let obj_cls = obj.class(); for cls in obj_cls.iter_mro() { if let Some(f) = cls.slots.as_buffer.as_ref() { - return f(obj, vm); + return obj.with_ptr(|obj| f(obj, vm)); } } Err(vm.new_type_error(format!( diff --git a/vm/src/types/slot.rs b/vm/src/types/slot.rs index f638615060..18bfb3ffe3 100644 --- a/vm/src/types/slot.rs +++ b/vm/src/types/slot.rs @@ -134,7 +134,7 @@ pub(crate) type HashFunc = fn(PyObjectPtr, &VirtualMachine) -> PyResult; pub(crate) type GetattroFunc = fn(PyObjectRef, PyStrRef, &VirtualMachine) -> PyResult; pub(crate) type SetattroFunc = fn(&PyObjectRef, PyStrRef, Option, &VirtualMachine) -> PyResult<()>; -pub(crate) type AsBufferFunc = fn(&PyObjectRef, &VirtualMachine) -> PyResult; +pub(crate) type AsBufferFunc = fn(PyObjectPtr, &VirtualMachine) -> PyResult; pub(crate) type RichCompareFunc = fn( PyObjectPtr, PyObjectPtr, @@ -754,7 +754,7 @@ pub trait AsBuffer: PyValue { // TODO: `flags` parameter #[inline] #[pyslot] - fn slot_as_buffer(zelf: &PyObjectRef, vm: &VirtualMachine) -> PyResult { + fn slot_as_buffer(zelf: PyObjectPtr, vm: &VirtualMachine) -> PyResult { let zelf = zelf .downcast_ref() .ok_or_else(|| vm.new_type_error("unexpected payload for as_buffer".to_owned()))?;