File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 1+ Fix compilation on ` wasm32-wasip2 ` .
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ impl<'py> IntoPyObject<'py> for &OsStr {
2323 #[ cfg( not( windows) ) ]
2424 {
2525 #[ cfg( target_os = "wasi" ) ]
26- let bytes = std :: os :: wasi:: ffi :: OsStrExt :: as_bytes ( self ) ;
26+ let bytes = self . to_str ( ) . expect ( " wasi strings are UTF8" ) . as_bytes ( ) ;
2727 #[ cfg( not( target_os = "wasi" ) ) ]
2828 let bytes = std:: os:: unix:: ffi:: OsStrExt :: as_bytes ( self ) ;
2929
@@ -87,9 +87,11 @@ impl FromPyObject<'_, '_> for OsString {
8787 } ;
8888
8989 // Create an OsStr view into the raw bytes from Python
90+ //
91+ // For WASI: OS strings are UTF-8 by definition.
9092 #[ cfg( target_os = "wasi" ) ]
9193 let os_str: & OsStr =
92- std :: os :: wasi :: ffi :: OsStrExt :: from_bytes ( fs_encoded_bytes. as_bytes ( ob. py ( ) ) ) ;
94+ OsStr :: new ( std :: str :: from_utf8 ( fs_encoded_bytes. as_bytes ( ob. py ( ) ) ) ? ) ;
9395 #[ cfg( not( target_os = "wasi" ) ) ]
9496 let os_str: & OsStr =
9597 std:: os:: unix:: ffi:: OsStrExt :: from_bytes ( fs_encoded_bytes. as_bytes ( ob. py ( ) ) ) ;
You can’t perform that action at this time.
0 commit comments