Skip to content

Commit 70f8849

Browse files
committed
as_buffer uses ptr
1 parent 08b5768 commit 70f8849

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

vm/src/protocol/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl TryFromBorrowedObject for PyBuffer {
108108
let obj_cls = obj.class();
109109
for cls in obj_cls.iter_mro() {
110110
if let Some(f) = cls.slots.as_buffer.as_ref() {
111-
return f(obj, vm);
111+
return obj.with_ptr(|obj| f(obj, vm));
112112
}
113113
}
114114
Err(vm.new_type_error(format!(

vm/src/types/slot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub(crate) type HashFunc = fn(PyObjectPtr, &VirtualMachine) -> PyResult<PyHash>;
134134
pub(crate) type GetattroFunc = fn(PyObjectRef, PyStrRef, &VirtualMachine) -> PyResult;
135135
pub(crate) type SetattroFunc =
136136
fn(&PyObjectRef, PyStrRef, Option<PyObjectRef>, &VirtualMachine) -> PyResult<()>;
137-
pub(crate) type AsBufferFunc = fn(&PyObjectRef, &VirtualMachine) -> PyResult<PyBuffer>;
137+
pub(crate) type AsBufferFunc = fn(PyObjectPtr, &VirtualMachine) -> PyResult<PyBuffer>;
138138
pub(crate) type RichCompareFunc = fn(
139139
PyObjectPtr,
140140
PyObjectPtr,
@@ -754,7 +754,7 @@ pub trait AsBuffer: PyValue {
754754
// TODO: `flags` parameter
755755
#[inline]
756756
#[pyslot]
757-
fn slot_as_buffer(zelf: &PyObjectRef, vm: &VirtualMachine) -> PyResult<PyBuffer> {
757+
fn slot_as_buffer(zelf: PyObjectPtr, vm: &VirtualMachine) -> PyResult<PyBuffer> {
758758
let zelf = zelf
759759
.downcast_ref()
760760
.ok_or_else(|| vm.new_type_error("unexpected payload for as_buffer".to_owned()))?;

0 commit comments

Comments
 (0)