File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
pyscript.core/src/plugins Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -51,21 +51,17 @@ hooks.onInterpreterReady.add(function override(pyScript) {
51
51
console . log ( "<py-terminal> not found, nothing to do" ) ;
52
52
return ;
53
53
}
54
- const { stdout, stderr } = pyScript . io ;
55
-
56
- pyScript . io . stdout = ( s , ...rest ) => {
57
- // XXX: the + "\n" is conceptually wrong.
58
- // We probably need to configure pyodide's stdout as "raw mode"
59
- // instead of "batched mode":
60
- // https://pyodide.org/en/stable/usage/streams.html#a-raw-handler
61
- t . write ( s + "\n" ) ;
62
- stdout ( s , ...rest ) ;
63
- }
64
-
65
- pyScript . io . stderr = ( s , ...rest ) => {
66
- t . write ( s + "\n" ) ; // see above for the "\n"
67
- stderr ( s , ...rest ) ;
54
+ // XXX: we should investigate pyodide "write handler", it should be more
55
+ // efficient:
56
+ // https://pyodide.org/en/stable/usage/streams.html#a-write-handler
57
+ //
58
+ // Also: should the stdout/stderr go ALSO to the JS console?
59
+ function myStdout ( byte ) {
60
+ t . write ( String . fromCharCode ( byte ) ) ;
68
61
}
62
+ const pyodide = pyScript . interpreter ;
63
+ pyodide . setStdout ( { raw : myStdout } ) ;
64
+ pyodide . setStderr ( { raw : myStdout } ) ;
69
65
} ) ;
70
66
71
67
You can’t perform that action at this time.
0 commit comments