8000 we can kill this ugly hack now · pyscript/pyscript@b60327f · GitHub
[go: up one dir, main page]

Skip to content

Commit b60327f

Browse files
committed
we can kill this ugly hack now
1 parent e2d27d2 commit b60327f

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

pyscript.core/src/core.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,9 @@ const registerModule = ({ XWorker: $XWorker, interpreter, io }) => {
7575
interpreter.runPython(stdlib, { globals: interpreter.runPython("{}") });
7676
};
7777

78-
// this is a super-ugly workaround for a polyscript issue: in theory I should
79-
// define a codeBeforeRunWorker hook inside py-terminal.js, but since it's a
80-
// lazy plugin, it is too late: https://github.com/pyscript/polyscript/issues/52
81-
const py_terminal_codeBeforeRunner = `
82-
from pyscript import pyterminal
83-
pyterminal.init()
84-
`;
85-
8678
const workerHooks = {
8779
codeBeforeRunWorker: () =>
88-
[stdlib, py_terminal_codeBeforeRunner, ...hooks.codeBeforeRunWorker]
89-
.map(dedent)
90-
.join("\n"),
80+
[stdlib, ...hooks.codeBeforeRunWorker].map(dedent).join("\n"),
9181
codeBeforeRunWorkerAsync: () =>
9282
[stdlib, ...hooks.codeBeforeRunWorkerAsync].map(dedent).join("\n"),
9383
codeAfterRunWorker: () =>

pyscript.core/src/plugins/py-terminal.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,8 @@ hooks.onWorkerReady.add(function (_, xworker) {
7575
xworker.sync.pyterminal_readline = t.readline;
7676
xworker.sync.pyterminal_write = t.write;
7777
});
78+
79+
hooks.codeBeforeRunWorker.add(`
80+
from pyscript import pyterminal
81+
pyterminal.init()
82+
`);

0 commit comments

Comments
 (0)
0