Skip to content

Commit 1a48fb1

Browse files
committed
Add PyContext.new_classmethod
1 parent cad4a13 commit 1a48fb1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

vm/src/pyobject.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::obj::objbool;
2121
use crate::obj::objbuiltinfunc::PyBuiltinFunction;
2222
use crate::obj::objbytearray;
2323
use crate::obj::objbytes;
24-
use crate::obj::objclassmethod;
24+
use crate::obj::objclassmethod::{self, PyClassMethod};
2525
use crate::obj::objcode;
2626
use crate::obj::objcode::PyCodeRef;
2727
use crate::obj::objcomplex::{self, PyComplex};
@@ -668,6 +668,19 @@ impl PyContext {
668668
)
669669
}
670670

671+
pub fn new_classmethod<F, T, R>(&self, f: F) -> PyObjectRef
672+
where
673+
F: IntoPyNativeFunc<T, R>,
674+
{
675+
PyObject::new(
676+
PyClassMethod {
677+
callable: self.new_rustfunc(f),
678+
},
679+
self.classmethod_type(),
680+
None,
681+
)
682+
}
683+
671684
pub fn new_property<F, I, V>(&self, f: F) -> PyObjectRef
672685
where
673686
F: IntoPyNativeFunc<I, V>,

0 commit comments

Comments
 (0)