mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Instrumented the io.stderr too when terminal exists (#1942)
This commit is contained in:
committed by
GitHub
parent
1e7fb9af44
commit
1efd73af8f
4
pyscript.core/package-lock.json
generated
4
pyscript.core/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pyscript/core",
|
"name": "@pyscript/core",
|
||||||
"version": "0.3.15",
|
"version": "0.3.16",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pyscript/core",
|
"name": "@pyscript/core",
|
||||||
"version": "0.3.15",
|
"version": "0.3.16",
|
||||||
"license": "APACHE-2.0",
|
"license": "APACHE-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ungap/with-resolvers": "^0.1.0",
|
"@ungap/with-resolvers": "^0.1.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pyscript/core",
|
"name": "@pyscript/core",
|
||||||
"version": "0.3.15",
|
"version": "0.3.16",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "PyScript",
|
"description": "PyScript",
|
||||||
"module": "./index.js",
|
"module": "./index.js",
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ const pyTerminal = async () => {
|
|||||||
if (element.hasAttribute("worker")) {
|
if (element.hasAttribute("worker")) {
|
||||||
// when the remote thread onReady triggers:
|
// when the remote thread onReady triggers:
|
||||||
// setup the interpreter stdout and stderr
|
// setup the interpreter stdout and stderr
|
||||||
const workerReady = ({ interpreter }, { sync }) => {
|
const workerReady = ({ interpreter, io }, { sync }) => {
|
||||||
sync.pyterminal_drop_hooks();
|
sync.pyterminal_drop_hooks();
|
||||||
|
|
||||||
// This part is inevitably duplicated as external scope
|
// This part is inevitably duplicated as external scope
|
||||||
@@ -106,6 +106,10 @@ const pyTerminal = async () => {
|
|||||||
isatty: true,
|
isatty: true,
|
||||||
stdin: () => sync.pyterminal_read(data),
|
stdin: () => sync.pyterminal_read(data),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
io.stderr = (error) => {
|
||||||
|
sync.pyterminal_write(`${error.message || error}\n`);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// add a hook on the main thread to setup all sync helpers
|
// add a hook on the main thread to setup all sync helpers
|
||||||
@@ -131,7 +135,7 @@ const pyTerminal = async () => {
|
|||||||
} else {
|
} else {
|
||||||
// in the main case, just bootstrap XTerm without
|
// in the main case, just bootstrap XTerm without
|
||||||
// allowing any input as that's not possible / awkward
|
// allowing any input as that's not possible / awkward
|
||||||
hooks.main.onReady.add(function main({ interpreter }) {
|
hooks.main.onReady.add(function main({ interpreter, io }) {
|
||||||
console.warn("py-terminal is read only on main thread");
|
console.warn("py-terminal is read only on main thread");
|
||||||
hooks.main.onReady.delete(main);
|
hooks.main.onReady.delete(main);
|
||||||
init({
|
init({
|
||||||
@@ -159,6 +163,10 @@ const pyTerminal = async () => {
|
|||||||
isatty: true,
|
isatty: true,
|
||||||
stdin: () => readline.read(data),
|
stdin: () => readline.read(data),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
io.stderr = (error) => {
|
||||||
|
readline.write(`${error.message || error}\n`);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user