diff --git a/tests/snippets/class.py b/tests/snippets/class.py index ded02dbfa..389c22712 100644 --- a/tests/snippets/class.py +++ b/tests/snippets/class.py @@ -152,3 +152,6 @@ class T4: assert T4.__doc__ == "test4" assert T4.t1.__doc__ == "t1" + +cm = classmethod(lambda cls: cls) +assert cm.__func__(int) is int diff --git a/vm/src/obj/objclassmethod.rs b/vm/src/obj/objclassmethod.rs index 69d6dba4e..10b3106ec 100644 --- a/vm/src/obj/objclassmethod.rs +++ b/vm/src/obj/objclassmethod.rs @@ -57,6 +57,11 @@ impl PyClassMethod { .ctx .new_bound_method(self.callable.clone(), owner.clone())) } + + #[pyproperty(name = "__func__")] + fn func(&self, _vm: &VirtualMachine) -> PyObjectRef { + self.callable.clone() + } } pub fn init(context: &PyContext) {