mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
vm.new_pyobj
This commit is contained in:
@@ -40,8 +40,8 @@ use crate::obj::objstr::{PyString, PyStringRef};
|
||||
use crate::obj::objtuple::PyTuple;
|
||||
use crate::obj::objtype::{self, PyClassRef};
|
||||
use crate::pyobject::{
|
||||
BorrowValue, IdProtocol, ItemProtocol, PyContext, PyObject, PyObjectRef, PyRef, PyResult,
|
||||
PyValue, TryFromObject, TryIntoRef, TypeProtocol,
|
||||
BorrowValue, IdProtocol, IntoPyObject, ItemProtocol, PyContext, PyObject, PyObjectRef, PyRef,
|
||||
PyResult, PyValue, TryFromObject, TryIntoRef, TypeProtocol,
|
||||
};
|
||||
use crate::scope::Scope;
|
||||
use crate::stdlib;
|
||||
@@ -379,6 +379,11 @@ impl VirtualMachine {
|
||||
class.downcast().expect("not a class")
|
||||
}
|
||||
|
||||
/// Create a new python object
|
||||
pub fn new_pyobj<T: IntoPyObject>(&self, value: T) -> PyObjectRef {
|
||||
value.into_pyobject(self)
|
||||
}
|
||||
|
||||
/// Create a new python string object.
|
||||
pub fn new_str(&self, s: String) -> PyObjectRef {
|
||||
self.ctx.new_str(s)
|
||||
|
||||
Reference in New Issue
Block a user