Fix PyObjectPayload usage in wasm
@@ -4,7 +4,7 @@ use js_sys::Promise;
use num_traits::cast::ToPrimitive;
use rustpython_vm::obj::{objint, objstr};
use rustpython_vm::pyobject::{
- PyContext, PyFuncArgs, PyObject, PyObjectPayload, PyObjectRef, PyResult, TypeProtocol,
+ PyContext, PyFuncArgs, PyObject, PyObjectRef, PyResult, TypeProtocol,
};
use rustpython_vm::{import::import, VirtualMachine};
use std::path::PathBuf;
@@ -157,21 +157,14 @@ pub struct PyPromise {
impl PyPromise {
pub fn new_obj(promise_type: PyObjectRef, value: Promise) -> PyObjectRef {
- PyObject::new(
- PyObjectPayload::AnyRustValue {
- value: Box::new(PyPromise { value }),
- },
- promise_type,
- )
+ PyObject::new(Box::new(PyPromise { value }), promise_type)
}
}
pub fn get_promise_value(obj: &PyObjectRef) -> Promise {
- if let PyObjectPayload::AnyRustValue { value } = &obj.payload {
- if let Some(promise) = value.downcast_ref::<PyPromise>() {
+ if let Some(promise) = obj.payload.downcast_ref::<PyPromise>() {
return promise.value.clone();
}
- }
panic!("Inner error getting promise")
}
