How to print to stdout during code running in

Sorry if this is the wrong discussion group.

I’m working on this issue:
[wasm32-emscripten] Emscripten node build is not portable to windows · Issue #96509 · python/cpython (

And because of this problem:
Debugging node emscripten builds? - WebAssembly - Discussions on

I have to printf debug everything.

This works fine when the problem is in the c code, but I’m at the point where something is failing in and I can’t just use ‘print’ because the builtins haven’t loaded yet.

Does anybody have any guidance on what I could use to print to stdout instead?

This is the error I get when using ‘print’ in

RuntimeError: lost sys.stdout

Ah, found it.

Using _verbose_message works if I launch with the -v flag.


Strange that it works, but maybe stderr is set but stdout isn’t.

Python sets an early stderr which is just enough to start Python, and quickly it’s replaced with a real class of the io module.