Skip to content

Commit 4510489

Browse files
Fix PyObjectPayload usage in wasm
1 parent 5971fc3 commit 4510489

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

wasm/lib/src/browser_module.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use js_sys::Promise;
44
use num_traits::cast::ToPrimitive;
55
use rustpython_vm::obj::{objint, objstr};
66
use rustpython_vm::pyobject::{
7-
PyContext, PyFuncArgs, PyObject, PyObjectPayload, PyObjectRef, PyResult, TypeProtocol,
7+
PyContext, PyFuncArgs, PyObject, PyObjectRef, PyResult, TypeProtocol,
88
};
99
use rustpython_vm::{import::import, VirtualMachine};
1010
use std::path::PathBuf;
@@ -157,20 +157,13 @@ pub struct PyPromise {
157157

158158
impl PyPromise {
159159
pub fn new_obj(promise_type: PyObjectRef, value: Promise) -> PyObjectRef {
160-
PyObject::new(
161-
PyObjectPayload::AnyRustValue {
162-
value: Box::new(PyPromise { value }),
163-
},
164-
promise_type,
165-
)
160+
PyObject::new(Box::new(PyPromise { value }), promise_type)
166161
}
167162
}
168163

169164
pub fn get_promise_value(obj: &PyObjectRef) -> Promise {
170-
if let PyObjectPayload::AnyRustValue { value } = &obj.payload {
171-
if let Some(promise) = value.downcast_ref::<PyPromise>() {
172-
return promise.value.clone();
173-
}
165+
if let Some(promise) = obj.payload.downcast_ref::<PyPromise>() {
166+
return promise.value.clone();
174167
}
175168
panic!("Inner error getting promise")
176169
}

0 commit comments

Comments
 (0)