Skip to content
Merged
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
Add method.__func__ property
  • Loading branch information
coolreader18 committed Apr 2, 2020
commit 53a6bc3f5874d734235e0835064f781c4b693ace
17 changes: 15 additions & 2 deletions vm/src/obj/objfunction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,22 @@ impl PyBoundMethod {
))
}

#[pyproperty(magic)]
fn doc(&self, vm: &VirtualMachine) -> PyResult {
vm.get_attribute(self.function.clone(), "__doc__")
}

#[pymethod(magic)]
fn getattribute(&self, name: PyStringRef, vm: &VirtualMachine) -> PyResult {
vm.get_attribute(self.function.clone(), name)
fn getattribute(zelf: PyRef<Self>, name: PyStringRef, vm: &VirtualMachine) -> PyResult {
if let Some(obj) = zelf.class().get_attr(name.as_str()) {
return vm.call_if_get_descriptor(obj, zelf.into_object());
}
vm.get_attribute(zelf.function.clone(), name)
}

#[pyproperty(magic)]
fn func(&self) -> PyObjectRef {
self.function.clone()
}
}

Expand Down