Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Convert __class__ descriptor to use new style functions
  • Loading branch information
skinnyBat committed Mar 7, 2019
commit 720bec2f4f480b8520736b7c5a95fa4b406855a9
16 changes: 7 additions & 9 deletions vm/src/obj/objobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,15 @@ fn object_init(vm: &mut VirtualMachine, _args: PyFuncArgs) -> PyResult {
Ok(vm.ctx.none())
}

fn object_class(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(
vm,
args,
required = [(_obj, None), (owner, Some(vm.ctx.type_type()))]
);
Ok(owner.clone())
fn object_class(_obj: PyObjectRef, owner: PyObjectRef, _vm: &mut VirtualMachine) -> PyObjectRef {
Comment thread
BenLewis-Seequent marked this conversation as resolved.
owner
}

fn object_class_setter(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(instance, None), (_value, None)]);
fn object_class_setter(
instance: PyObjectRef,
_value: PyObjectRef,
vm: &mut VirtualMachine,
) -> PyResult {
let type_repr = vm.to_pystr(&instance.typ())?;
Err(vm.new_type_error(format!("can't change class of type '{}'", type_repr)))
}
Expand Down
6 changes: 4 additions & 2 deletions vm/src/pyobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,10 @@ impl PyContext {
}

pub fn new_data_descriptor<
G: 'static + Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult,
S: 'static + Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult,
G: IntoPyNativeFunc<(I, PyObjectRef), T>,
S: IntoPyNativeFunc<(I, T), PyResult>,
T,
I,
>(
&self,
getter: G,
Expand Down