sagemathinc / cowasm

CoWasm: Collaborative WebAssembly for Servers and Browsers. Built using Zig. Supports Python with extension modules, including numpy.
https://cowasm.org
BSD 3-Clause "New" or "Revised" License
482 stars 23 forks source link

improve os.popen stub #16

Closed williamstein closed 1 year ago

williamstein commented 1 year ago

Right now attempts to use os.popen crash the entire python process:

~/python-wasm/packages/cpython$ ../../bin/python-wasm 
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> iPython 3.11.0b3 (main, Jul 23 2022, 06:21:39) [Clang 13.0.1 (git@github.com:ziglang/zig-bootstrap.git 623481199fe17f4311cbdbbf on wasi
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.popen('ls')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen os>", line 986, in popen
  File "/Users/wstein/build/cocalc/src/data/projects/2c9318d1-4f8b-4910-8da7-68a965514c95/python-wasm/packages/cpython/build/wasm/Lib/subprocess.py", line 805, in __init__
OSError: [Errno 58] wasi does not support processes.
>>> 
~/python-wasm/packages/cpython$ 

It would be better if instead you see an error but the whole process doesn't exit. This must be possible, and might just involve improving whatever stub is being called.

The above error message comes from:

lib/python3.11/subprocess.py:                errno.ENOTSUP, f"{sys.platform} does not support processes."
williamstein commented 1 year ago

This now works fine (under node.js of course).