Skip to content

Commit df20a26

Browse files
committed
vm.new_pyobj
1 parent 4506e21 commit df20a26

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

vm/src/vm.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ use crate::obj::objstr::{PyString, PyStringRef};
4040
use crate::obj::objtuple::PyTuple;
4141
use crate::obj::objtype::{self, PyClassRef};
4242
use crate::pyobject::{
43-
BorrowValue, IdProtocol, ItemProtocol, PyContext, PyObject, PyObjectRef, PyRef, PyResult,
44-
PyValue, TryFromObject, TryIntoRef, TypeProtocol,
43+
BorrowValue, IdProtocol, IntoPyObject, ItemProtocol, PyContext, PyObject, PyObjectRef, PyRef,
44+
PyResult, PyValue, TryFromObject, TryIntoRef, TypeProtocol,
4545
};
4646
use crate::scope::Scope;
4747
use crate::stdlib;
@@ -379,6 +379,11 @@ impl VirtualMachine {
379379
class.downcast().expect("not a class")
380380
}
381381

382+
/// Create a new python object
383+
pub fn new_pyobj<T: IntoPyObject>(&self, value: T) -> PyObjectRef {
384+
value.into_pyobject(self)
385+
}
386+
382387
/// Create a new python string object.
383388
pub fn new_str(&self, s: String) -> PyObjectRef {
384389
self.ctx.new_str(s)

0 commit comments

Comments
 (0)