Skip to content

Commit 7564833

Browse files
committed
Add classmethod.__func__
1 parent b720681 commit 7564833

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

tests/snippets/class.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,6 @@ def t1(self):
152152

153153
assert T4.__doc__ == "test4"
154154
assert T4.t1.__doc__ == "t1"
155+
156+
cm = classmethod(lambda cls: cls)
157+
assert cm.__func__(int) is int

vm/src/obj/objclassmethod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ impl PyClassMethod {
5757
.ctx
5858
.new_bound_method(self.callable.clone(), owner.clone()))
5959
}
60+
61+
#[pyproperty(name = "__func__")]
62+
fn func(&self, _vm: &VirtualMachine) -> PyObjectRef {
63+
self.callable.clone()
64+
}
6065
}
6166

6267
pub fn init(context: &PyContext) {

0 commit comments

Comments
 (0)