From d148bdd46c3aec5c575b0623c4137a517a440f21 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sat, 28 Mar 2020 00:38:58 +0900 Subject: [PATCH] Basic bound method repr --- vm/src/obj/objfunction.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vm/src/obj/objfunction.rs b/vm/src/obj/objfunction.rs index bb3af08f49..703c8bfae8 100644 --- a/vm/src/obj/objfunction.rs +++ b/vm/src/obj/objfunction.rs @@ -271,7 +271,7 @@ impl PyFunction { #[derive(Debug)] pub struct PyBoundMethod { // TODO: these shouldn't be public - pub object: PyObjectRef, + object: PyObjectRef, pub function: PyObjectRef, } @@ -290,6 +290,14 @@ impl PyBoundMethod { #[pyimpl(with(SlotCall))] impl PyBoundMethod { + #[pymethod(magic)] + fn repr(&self, vm: &VirtualMachine) -> PyResult { + Ok(format!( + "", + vm.to_repr(&self.object)?.as_str() + )) + } + #[pymethod(magic)] fn getattribute(&self, name: PyStringRef, vm: &VirtualMachine) -> PyResult { vm.get_attribute(self.function.clone(), name)