Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
Protect Pyodide runtime from being polluted
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Feb 27, 2024
1 parent eadfb23 commit 6a1f443
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/helpers/getPythonResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export const getPythonResult = async (
messageCallback: (x) => onImporting(x, false),
});
}
await pyodide.runPythonAsync(code);
const dict = pyodide.globals.get("dict");
const globals = dict();
await pyodide.runPythonAsync(code, { globals, locals: globals });
globals.destroy();
dict.destroy();
} catch (e) {
let err = String(e);
if (err.endsWith("\n")) {
Expand Down

0 comments on commit 6a1f443

Please sign in to comment.