Skip to content

Failing to build for target wasm32-unknown-unknown #2378

Closed
@vnetserg

Description

@vnetserg

Right now building for wasm32-unknown-unknown yields the following error:

error[E0599]: no method named `into_pyexception` found for struct `std::io::Error` in the current scope
   --> vm/src/stdlib/thread.rs:243:28
    |
243 |         .map_err(|err| err.into_pyexception(vm))
    |                            ^^^^^^^^^^^^^^^^ method not found in `std::io::Error

This is fairly trivial to fix though:

diff --git a/vm/src/stdlib/thread.rs b/vm/src/stdlib/thread.rs
index 8c48761d..afa42eac 100644
--- a/vm/src/stdlib/thread.rs
+++ b/vm/src/stdlib/thread.rs
@@ -240,7 +240,16 @@ fn _thread_start_new_thread(
             vm.state.thread_count.fetch_add(1);
             thread_to_id(&handle.thread())
         })
-        .map_err(|err| err.into_pyexception(vm))
+        .map_err(|err| {
+            #[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
+            {
+                err.into_pyexception(vm)
+            }
+            #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
+            {
+                vm.new_os_error(err.to_string())
+            }
+        })
 }
 
 fn run_thread(func: PyCallable, args: FuncArgs, vm: &VirtualMachine) {

Another option would be to compile without "threading" feature. I am not sure if this is intentional that it fails to compile with threading enabled?

P.S. Thank you for your hard work on RustPython, I really love the project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions