@@ -4,9 +4,10 @@ use js_sys::Promise;
4
4
use num_traits:: cast:: ToPrimitive ;
5
5
use rustpython_vm:: obj:: { objint, objstr} ;
6
6
use rustpython_vm:: pyobject:: {
7
- PyContext , PyFuncArgs , PyObject , PyObjectPayload , PyObjectRef , PyResult , TypeProtocol ,
7
+ AttributeProtocol , PyContext , PyFuncArgs , PyObject , PyObjectPayload , PyObjectRef , PyResult ,
8
+ TypeProtocol ,
8
9
} ;
9
- use rustpython_vm:: { import:: import , VirtualMachine } ;
10
+ use rustpython_vm:: { import:: import_module , VirtualMachine } ;
10
11
use std:: path:: PathBuf ;
11
12
use wasm_bindgen:: { prelude:: * , JsCast } ;
12
13
use wasm_bindgen_futures:: { future_to_promise, JsFuture } ;
@@ -176,12 +177,10 @@ pub fn get_promise_value(obj: &PyObjectRef) -> Promise {
176
177
}
177
178
178
179
pub fn import_promise_type ( vm : & mut VirtualMachine ) -> PyResult {
179
- import (
180
- vm,
181
- PathBuf :: default ( ) ,
182
- BROWSER_NAME ,
183
- & Some ( "Promise" . into ( ) ) ,
184
- )
180
+ match import_module ( vm, PathBuf :: default ( ) , BROWSER_NAME ) ?. get_attr ( "Promise" . into ( ) ) {
181
+ Some ( promise) => Ok ( promise) ,
182
+ None => Err ( vm. new_not_implemented_error ( "No Promise" . to_string ( ) ) ) ,
183
+ }
185
184
}
186
185
187
186
fn promise_then ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
0 commit comments