Skip to content

Commit a15972b

Browse files
Implement build_method_def for METH_O
1 parent 397f6f5 commit a15972b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

crates/capi/src/methodobject.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ pub(crate) fn build_method_def(vm: &VirtualMachine, ml: &PyMethodDef) -> PyRef<H
168168
vm.ctx.new_method_def(name, callable, flags, doc)
169169
},
170170
PyMethodFlags::O => {
171-
let callable = move |_args: FuncArgs, _vm: &VirtualMachine| -> PyResult {
172-
todo!("METH_O is not supported yet")
171+
let f = unsafe { method.PyCFunction };
172+
let callable = move |zelf: PyObjectRef, arg: PyObjectRef, vm: &VirtualMachine| -> PyResult {
173+
let ret_ptr = unsafe { f(zelf.as_raw().cast_mut(), arg.as_raw().cast_mut()) };
174+
ret_ptr_to_pyresult(vm, ret_ptr)
173175
};
174176
vm.ctx.new_method_def(name, callable, flags, doc)
175177
},

0 commit comments

Comments
 (0)