mirror of https://github.com/pyodide/pyodide.git
![]() Resolves https://github.com/pyodide/pyodide/issues/3112 This adds a carefully designed API for controlling stdin, stdout, and stderr. It changes the default behavior to be a bit more useful, though in doing so introduces some mild backwards incompatibility. In particular: 1. By default, stdin reads directly from `process.stdin` in node (as before) and raises an error if in browser (not as before). 2. By default, stdout writes directly to `process.stdout` in node (before it called console.log) and calls console.log in browser (as before). 3. By default, stderr writes directly to `process.stderr` in node (before it called console.warn) and calls console.warn in browser (as before). 4. In all three cases, by default isatty(stdin/stdout/stderr) is true in node and false in browser (in the browser it used to be true). 5. As before, if you pass `stdin`, `stdout`, or `stderr` as arguments to `loadPyodide`, `isatty` of the corresponding stream is set to false. The stdin function is now more flexible: we now correctly handle the case where it returns an ArrayBuffer or ArrayBufferView. I also added 3 new functions to set streams after Pyodide is loaded which offer additional control: * `setStdin({stdin?, error?, isatty = false})` -- Sets the stdin function. The stdin function takes no arguments and should return null, undefined, a string, or a buffer. Sets and `isatty(stdin)` to `isatty` (by default `false`). If error is true, set stdin to always raise an EIO error when it is read. * `setStdout({raw?, batched?, isatty = false})` -- If neither raw nor batched is passed, restore default stdout behavior. If rwa is passed, the raw stdout function receives a byte which it should interpret as a utf8 character code. Sets `isatty(stdout)` to isatty (by default `false`). If batched is passed but not raw, it sets a batched stdout function. The stdout function receives a string and should do something with it. In this case it ignores isatty and sets isatty(stdout) to false. * `setStderr({raw?, batched?, isatty = false})` -- same but with stderr. |
||
---|---|---|
.. | ||
cmake/Modules/Platform | ||
symlinks | ||
assemble_wat.js | ||
buildf2c | ||
bump_version.py | ||
calculate_build_cache_key.py | ||
dependency-check.sh | ||
deploy_to_npm.sh | ||
pyo3_config.ini | ||
pytest_wrapper.py | ||
python |